diff --git a/README.md b/README.md index f4b54e4a..514e7d10 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,7 @@ The currently supported libraries include: * [c/llama2](https://pkg.go.dev/github.com/goplus/llgo/c/llama2) * [c/lua](https://pkg.go.dev/github.com/goplus/llgo/c/lua) * [c/neco](https://pkg.go.dev/github.com/goplus/llgo/c/neco) +* [c/openssl](https://pkg.go.dev/github.com/goplus/llgo/c/openssl) * [c/raylib](https://pkg.go.dev/github.com/goplus/llgo/c/raylib) * [c/sqlite](https://pkg.go.dev/github.com/goplus/llgo/c/sqlite) * [c/zlib](https://pkg.go.dev/github.com/goplus/llgo/c/zlib) diff --git a/c/openssl/sha.go b/c/openssl/sha.go deleted file mode 100644 index 3cf7d891..00000000 --- a/c/openssl/sha.go +++ /dev/null @@ -1,31 +0,0 @@ -package openssl - -import "github.com/goplus/llgo/c" - -const ( - SHA_DIGEST_LENGTH = 20 - SHA_LBLOCK = 16 - SHA_CBLOCK = (SHA_LBLOCK * 4) - SHA_LAST_BLOCK = (SHA_CBLOCK - 8) - - SHA256_CBLOCK = (SHA_LBLOCK * 4) - SHA256_192_DIGEST_LENGTH = 24 - SHA224_DIGEST_LENGTH = 28 - SHA256_DIGEST_LENGTH = 32 - SHA384_DIGEST_LENGTH = 48 - SHA512_DIGEST_LENGTH = 64 - SHA512_CBLOCK = (SHA_LBLOCK * 8) -) - -/* -# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -# define SHA_LONG64 unsigned __int64 -# elif defined(__arch64__) -# define SHA_LONG64 unsigned long -# else -# define SHA_LONG64 unsigned long long -# endif -*/ -type SHA_LONG64 = c.UlongLong - -type SHA_LONG = c.Uint diff --git a/c/openssl/sha1.go b/c/openssl/sha1.go index 96da515d..4ad88ca9 100644 --- a/c/openssl/sha1.go +++ b/c/openssl/sha1.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package openssl import ( @@ -6,6 +22,25 @@ import ( "github.com/goplus/llgo/c" ) +const ( + SHA_DIGEST_LENGTH = 20 + SHA_LBLOCK = 16 + SHA_CBLOCK = (SHA_LBLOCK * 4) + SHA_LAST_BLOCK = (SHA_CBLOCK - 8) + + SHA256_CBLOCK = (SHA_LBLOCK * 4) + SHA256_192_DIGEST_LENGTH = 24 + SHA224_DIGEST_LENGTH = 28 + SHA256_DIGEST_LENGTH = 32 + SHA384_DIGEST_LENGTH = 48 + SHA512_DIGEST_LENGTH = 64 + SHA512_CBLOCK = (SHA_LBLOCK * 8) +) + +type SHA_LONG64 = c.UlongLong + +type SHA_LONG = c.Uint + type SHA_CTX struct { H0, H1, H2, H3, H4 SHA_LONG Nl, Nh SHA_LONG diff --git a/c/openssl/sha256.go b/c/openssl/sha256.go index 2934208d..f7bd9f82 100644 --- a/c/openssl/sha256.go +++ b/c/openssl/sha256.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package openssl import ( diff --git a/c/openssl/sha512.go b/c/openssl/sha512.go index 85431af8..ec2e0739 100644 --- a/c/openssl/sha512.go +++ b/c/openssl/sha512.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package openssl import (