-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
3,519 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package ossl | ||
|
||
const ( | ||
KeyTypeRSA = "RSA\x00" | ||
KeyTypeEC = "EC\x00" | ||
KeyTypeED25519 = "ED25519\x00" | ||
) | ||
|
||
const ( | ||
OSSL_KDF_NAME_HKDF = "HKDF\x00" | ||
OSSL_KDF_NAME_PBKDF2 = "PBKDF2\x00" | ||
OSSL_KDF_NAME_TLS1_PRF = "TLS1-PRF\x00" | ||
OSSL_MAC_NAME_HMAC = "HMAC\x00" | ||
) | ||
|
||
const POINT_CONVERSION_UNCOMPRESSED = 4 | ||
|
||
// #include <openssl/crypto.h> | ||
const ( | ||
OPENSSL_INIT_LOAD_CRYPTO_STRINGS = 0x00000002 | ||
OPENSSL_INIT_ADD_ALL_CIPHERS = 0x00000004 | ||
OPENSSL_INIT_ADD_ALL_DIGESTS = 0x00000008 | ||
OPENSSL_INIT_LOAD_CONFIG = 0x00000040 | ||
) | ||
|
||
// #include <openssl/evp.h> | ||
const ( | ||
EVP_CTRL_GCM_GET_TAG = 0x10 | ||
EVP_CTRL_GCM_SET_TAG = 0x11 | ||
EVP_PKEY_CTRL_MD = 1 | ||
EVP_PKEY_RSA = 6 | ||
EVP_PKEY_EC = 408 | ||
EVP_PKEY_TLS1_PRF = 1021 | ||
EVP_PKEY_HKDF = 1036 | ||
EVP_PKEY_ED25519 = 1087 | ||
EVP_PKEY_DSA = 116 | ||
/* This is defined differently in OpenSSL 3 (1 << 11), but in our | ||
* code it is only used in OpenSSL 1. | ||
*/ | ||
GO1_EVP_PKEY_OP_DERIVE = (1 << 10) | ||
EVP_MAX_MD_SIZE = 64 | ||
|
||
EVP_PKEY_PUBLIC_KEY = 0x86 | ||
EVP_PKEY_KEYPAIR = 0x87 | ||
) | ||
|
||
// #include <openssl/ec.h> | ||
const ( | ||
EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID = 0x1001 | ||
) | ||
|
||
// #include <openssl/kdf.h> | ||
const ( | ||
EVP_KDF_HKDF_MODE_EXTRACT_ONLY = 1 | ||
EVP_KDF_HKDF_MODE_EXPAND_ONLY = 2 | ||
|
||
EVP_PKEY_CTRL_TLS_MD = 0x1000 | ||
EVP_PKEY_CTRL_TLS_SECRET = 0x1001 | ||
EVP_PKEY_CTRL_TLS_SEED = 0x1002 | ||
EVP_PKEY_CTRL_HKDF_MD = 0x1003 | ||
EVP_PKEY_CTRL_HKDF_SALT = 0x1004 | ||
EVP_PKEY_CTRL_HKDF_KEY = 0x1005 | ||
EVP_PKEY_CTRL_HKDF_INFO = 0x1006 | ||
EVP_PKEY_CTRL_HKDF_MODE = 0x1007 | ||
) | ||
|
||
// #include <openssl/obj_mac.h> | ||
const ( | ||
NID_X9_62_prime256v1 = 415 | ||
NID_secp224r1 = 713 | ||
NID_secp384r1 = 715 | ||
NID_secp521r1 = 716 | ||
) | ||
|
||
// #include <openssl/rsa.h> | ||
const ( | ||
RSA_PKCS1_PADDING = 1 | ||
RSA_NO_PADDING = 3 | ||
RSA_PKCS1_OAEP_PADDING = 4 | ||
RSA_PKCS1_PSS_PADDING = 6 | ||
RSA_PSS_SALTLEN_DIGEST = -1 | ||
RSA_PSS_SALTLEN_AUTO = -2 | ||
RSA_PSS_SALTLEN_MAX_SIGN = -2 | ||
RSA_PSS_SALTLEN_MAX = -3 | ||
EVP_PKEY_CTRL_RSA_PADDING = 0x1001 | ||
EVP_PKEY_CTRL_RSA_PSS_SALTLEN = 0x1002 | ||
EVP_PKEY_CTRL_RSA_KEYGEN_BITS = 0x1003 | ||
EVP_PKEY_CTRL_RSA_MGF1_MD = 0x1005 | ||
EVP_PKEY_CTRL_RSA_OAEP_MD = 0x1009 | ||
EVP_PKEY_CTRL_RSA_OAEP_LABEL = 0x100A | ||
EVP_PKEY_CTRL_DSA_PARAMGEN_BITS = 0x1001 | ||
EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS = 0x1002 | ||
) | ||
|
||
const ( | ||
// KDF parameters | ||
OSSL_KDF_PARAM_DIGEST = "digest\x00" | ||
OSSL_KDF_PARAM_SECRET = "secret\x00" | ||
OSSL_KDF_PARAM_SEED = "seed\x00" | ||
OSSL_KDF_PARAM_KEY = "key\x00" | ||
OSSL_KDF_PARAM_INFO = "info\x00" | ||
OSSL_KDF_PARAM_SALT = "salt\x00" | ||
OSSL_KDF_PARAM_MODE = "mode\x00" | ||
|
||
// PKEY parameters | ||
OSSL_PKEY_PARAM_PUB_KEY = "pub\x00" | ||
OSSL_PKEY_PARAM_PRIV_KEY = "priv\x00" | ||
OSSL_PKEY_PARAM_GROUP_NAME = "group\x00" | ||
OSSL_PKEY_PARAM_EC_PUB_X = "qx\x00" | ||
OSSL_PKEY_PARAM_EC_PUB_Y = "qy\x00" | ||
OSSL_PKEY_PARAM_FFC_PBITS = "pbits\x00" | ||
OSSL_PKEY_PARAM_FFC_QBITS = "qbits\x00" | ||
OSSL_PKEY_PARAM_RSA_N = "n\x00" | ||
OSSL_PKEY_PARAM_RSA_E = "e\x00" | ||
OSSL_PKEY_PARAM_RSA_D = "d\x00" | ||
OSSL_PKEY_PARAM_FFC_P = "p\x00" | ||
OSSL_PKEY_PARAM_FFC_Q = "q\x00" | ||
OSSL_PKEY_PARAM_FFC_G = "g\x00" | ||
OSSL_PKEY_PARAM_RSA_FACTOR1 = "rsa-factor1\x00" | ||
OSSL_PKEY_PARAM_RSA_FACTOR2 = "rsa-factor2\x00" | ||
OSSL_PKEY_PARAM_RSA_EXPONENT1 = "rsa-exponent1\x00" | ||
OSSL_PKEY_PARAM_RSA_EXPONENT2 = "rsa-exponent2\x00" | ||
OSSL_PKEY_PARAM_RSA_COEFFICIENT1 = "rsa-coefficient1\x00" | ||
|
||
// MAC parameters | ||
OSSL_MAC_PARAM_DIGEST = "digest\x00" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//go:build cgo | ||
|
||
package ossl | ||
|
||
//go:generate go run github.com/golang-fips/openssl/v2/internal/mkcgo -out zossl.go --package ossl --lib crypto --include ossl.h api.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#pragma GCC diagnostic ignored "-Wattributes" | ||
|
||
#ifndef OSSL_H | ||
#define OSSL_H | ||
|
||
// Suppress warnings about unused parameters. | ||
#define UNUSED(x) (void)(x) | ||
|
||
// #include <openssl/evp.h> | ||
enum { | ||
EVP_CTRL_GCM_GET_TAG = 0x10, | ||
EVP_CTRL_GCM_SET_TAG = 0x11, | ||
}; | ||
|
||
typedef int point_conversion_form_t; | ||
|
||
typedef void* OPENSSL_INIT_SETTINGS_PTR; | ||
typedef void* OSSL_LIB_CTX_PTR; | ||
typedef void* OSSL_PROVIDER_PTR; | ||
typedef void* ENGINE_PTR; | ||
typedef void* EVP_PKEY_PTR; | ||
typedef void* EVP_PKEY_CTX_PTR; | ||
typedef void* EVP_MD_PTR; | ||
typedef void* EVP_MD_CTX_PTR; | ||
typedef void* HMAC_CTX_PTR; | ||
typedef void* EVP_CIPHER_PTR; | ||
typedef void* EVP_CIPHER_CTX_PTR; | ||
typedef void* EC_KEY_PTR; | ||
typedef void* EC_POINT_PTR; | ||
typedef void* EC_GROUP_PTR; | ||
typedef void* RSA_PTR; | ||
typedef void* BIGNUM_PTR; | ||
typedef void* BN_CTX_PTR; | ||
typedef void* EVP_MAC_PTR; | ||
typedef void* EVP_MAC_CTX_PTR; | ||
typedef void* OSSL_PARAM_BLD_PTR; | ||
typedef void* OSSL_PARAM_PTR; | ||
typedef void* CRYPTO_THREADID_PTR; | ||
typedef void* EVP_SIGNATURE_PTR; | ||
typedef void* DSA_PTR; | ||
typedef void* EVP_KDF_PTR; | ||
typedef void* EVP_KDF_CTX_PTR; | ||
typedef void* MD5_CTX_PTR; | ||
typedef void* SHA_CTX_PTR; | ||
|
||
typedef void threadid_func(CRYPTO_THREADID_PTR); | ||
typedef void locking_func(int mode, int n, const char *file, int line); | ||
|
||
#endif // OSSL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build cgo | ||
|
||
package ossl | ||
|
||
import "C" | ||
|
||
type Point_conversion_form_t = C.point_conversion_form_t | ||
|
||
type OPENSSL_INIT_SETTINGS_PTR = C.OPENSSL_INIT_SETTINGS_PTR | ||
type OSSL_LIB_CTX_PTR = C.OSSL_LIB_CTX_PTR | ||
type OSSL_PROVIDER_PTR = C.OSSL_PROVIDER_PTR | ||
type ENGINE_PTR = C.ENGINE_PTR | ||
type EVP_PKEY_PTR = C.EVP_PKEY_PTR | ||
type EVP_PKEY_CTX_PTR = C.EVP_PKEY_CTX_PTR | ||
type EVP_MD_PTR = C.EVP_MD_PTR | ||
type EVP_MD_CTX_PTR = C.EVP_MD_CTX_PTR | ||
type HMAC_CTX_PTR = C.HMAC_CTX_PTR | ||
type EVP_CIPHER_PTR = C.EVP_CIPHER_PTR | ||
type EVP_CIPHER_CTX_PTR = C.EVP_CIPHER_CTX_PTR | ||
type EC_KEY_PTR = C.EC_KEY_PTR | ||
type EC_POINT_PTR = C.EC_POINT_PTR | ||
type EC_GROUP_PTR = C.EC_GROUP_PTR | ||
type RSA_PTR = C.RSA_PTR | ||
type BIGNUM_PTR = C.BIGNUM_PTR | ||
type BN_CTX_PTR = C.BN_CTX_PTR | ||
type EVP_MAC_PTR = C.EVP_MAC_PTR | ||
type EVP_MAC_CTX_PTR = C.EVP_MAC_CTX_PTR | ||
type OSSL_PARAM_BLD_PTR = C.OSSL_PARAM_BLD_PTR | ||
type OSSL_PARAM_PTR = C.OSSL_PARAM_PTR | ||
type CRYPTO_THREADID_PTR = C.CRYPTO_THREADID_PTR | ||
type EVP_SIGNATURE_PTR = C.EVP_SIGNATURE_PTR | ||
type DSA_PTR = C.DSA_PTR | ||
type EVP_KDF_PTR = C.EVP_KDF_PTR | ||
type EVP_KDF_CTX_PTR = C.EVP_KDF_CTX_PTR | ||
type MD5_CTX_PTR = C.MD5_CTX_PTR | ||
type SHA_CTX_PTR = C.SHA_CTX_PTR |
Oops, something went wrong.