Ungate constants and gate tests
parent
3327d9ae39
commit
e58d81533c
|
@ -432,21 +432,22 @@ if _lib.RSA_ENABLED:
|
||||||
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
||||||
assert plaintext == rsa_private.verify(signature)
|
assert plaintext == rsa_private.verify(signature)
|
||||||
|
|
||||||
def test_rsa_pss_sign_verify(rsa_private, rsa_public):
|
if _lib.RSA_PSS_ENABLED:
|
||||||
plaintext = t2b("Everyone gets Friday off yippee.")
|
def test_rsa_pss_sign_verify(rsa_private, rsa_public):
|
||||||
|
plaintext = t2b("Everyone gets Friday off yippee.")
|
||||||
|
|
||||||
# normal usage, sign with private, verify with public
|
# normal usage, sign with private, verify with public
|
||||||
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
|
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
|
||||||
|
|
||||||
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
||||||
assert 0 == rsa_public.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
|
assert 0 == rsa_public.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
|
||||||
|
|
||||||
# private object holds both private and public info, so it can also verify
|
# private object holds both private and public info, so it can also verify
|
||||||
# using the known public key.
|
# using the known public key.
|
||||||
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
|
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
|
||||||
|
|
||||||
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
assert 1024 / 8 == len(signature) == rsa_private.output_size
|
||||||
assert 0 == rsa_private.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
|
assert 0 == rsa_private.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
|
||||||
|
|
||||||
def test_rsa_sign_verify_pem(rsa_private_pem, rsa_public_pem):
|
def test_rsa_sign_verify_pem(rsa_private_pem, rsa_public_pem):
|
||||||
plaintext = t2b("Everyone gets Friday off.")
|
plaintext = t2b("Everyone gets Friday off.")
|
||||||
|
|
|
@ -372,6 +372,34 @@ if HMAC_ENABLED:
|
||||||
|
|
||||||
if RSA_ENABLED:
|
if RSA_ENABLED:
|
||||||
_cdef += """
|
_cdef += """
|
||||||
|
static const int WC_RSA_PKCSV15_PAD;
|
||||||
|
static const int WC_RSA_OAEP_PAD;
|
||||||
|
static const int WC_RSA_PSS_PAD;
|
||||||
|
static const int WC_RSA_NO_PAD;
|
||||||
|
|
||||||
|
static const int WC_MGF1NONE;
|
||||||
|
static const int WC_MGF1SHA1;
|
||||||
|
static const int WC_MGF1SHA224;
|
||||||
|
static const int WC_MGF1SHA256;
|
||||||
|
static const int WC_MGF1SHA384;
|
||||||
|
static const int WC_MGF1SHA512;
|
||||||
|
|
||||||
|
static const int WC_HASH_TYPE_NONE;
|
||||||
|
static const int WC_HASH_TYPE_MD2;
|
||||||
|
static const int WC_HASH_TYPE_MD4;
|
||||||
|
static const int WC_HASH_TYPE_MD5;
|
||||||
|
static const int WC_HASH_TYPE_SHA;
|
||||||
|
static const int WC_HASH_TYPE_SHA224;
|
||||||
|
static const int WC_HASH_TYPE_SHA256;
|
||||||
|
static const int WC_HASH_TYPE_SHA384;
|
||||||
|
static const int WC_HASH_TYPE_SHA512;
|
||||||
|
static const int WC_HASH_TYPE_MD5_SHA;
|
||||||
|
static const int WC_HASH_TYPE_SHA3_224;
|
||||||
|
static const int WC_HASH_TYPE_SHA3_256;
|
||||||
|
static const int WC_HASH_TYPE_SHA3_384;
|
||||||
|
static const int WC_HASH_TYPE_SHA3_512;
|
||||||
|
static const int WC_HASH_TYPE_BLAKE2B;
|
||||||
|
static const int WC_HASH_TYPE_BLAKE2S;
|
||||||
typedef struct {...; } RsaKey;
|
typedef struct {...; } RsaKey;
|
||||||
|
|
||||||
int wc_InitRsaKey(RsaKey* key, void*);
|
int wc_InitRsaKey(RsaKey* key, void*);
|
||||||
|
@ -392,37 +420,9 @@ if RSA_ENABLED:
|
||||||
byte* out, word32 outLen, RsaKey* key, int type,
|
byte* out, word32 outLen, RsaKey* key, int type,
|
||||||
enum wc_HashType hash, int mgf, byte* label, word32 labelSz);
|
enum wc_HashType hash, int mgf, byte* label, word32 labelSz);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if RSA_PSS_ENABLED:
|
if RSA_PSS_ENABLED:
|
||||||
_cdef += """
|
_cdef += """
|
||||||
static const int WC_RSA_PKCSV15_PAD;
|
|
||||||
static const int WC_RSA_OAEP_PAD;
|
|
||||||
static const int WC_RSA_PSS_PAD;
|
|
||||||
static const int WC_RSA_NO_PAD;
|
|
||||||
|
|
||||||
static const int WC_MGF1NONE;
|
|
||||||
static const int WC_MGF1SHA1;
|
|
||||||
static const int WC_MGF1SHA224;
|
|
||||||
static const int WC_MGF1SHA256;
|
|
||||||
static const int WC_MGF1SHA384;
|
|
||||||
static const int WC_MGF1SHA512;
|
|
||||||
|
|
||||||
static const int WC_HASH_TYPE_NONE;
|
|
||||||
static const int WC_HASH_TYPE_MD2;
|
|
||||||
static const int WC_HASH_TYPE_MD4;
|
|
||||||
static const int WC_HASH_TYPE_MD5;
|
|
||||||
static const int WC_HASH_TYPE_SHA;
|
|
||||||
static const int WC_HASH_TYPE_SHA224;
|
|
||||||
static const int WC_HASH_TYPE_SHA256;
|
|
||||||
static const int WC_HASH_TYPE_SHA384;
|
|
||||||
static const int WC_HASH_TYPE_SHA512;
|
|
||||||
static const int WC_HASH_TYPE_MD5_SHA;
|
|
||||||
static const int WC_HASH_TYPE_SHA3_224;
|
|
||||||
static const int WC_HASH_TYPE_SHA3_256;
|
|
||||||
static const int WC_HASH_TYPE_SHA3_384;
|
|
||||||
static const int WC_HASH_TYPE_SHA3_512;
|
|
||||||
static const int WC_HASH_TYPE_BLAKE2B;
|
|
||||||
static const int WC_HASH_TYPE_BLAKE2S;
|
|
||||||
|
|
||||||
int wc_RsaPSS_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
|
int wc_RsaPSS_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
|
||||||
enum wc_HashType hash, int mgf, RsaKey* key, WC_RNG* rng);
|
enum wc_HashType hash, int mgf, RsaKey* key, WC_RNG* rng);
|
||||||
int wc_RsaPSS_Verify(byte* in, word32 inLen, byte* out, word32 outLen,
|
int wc_RsaPSS_Verify(byte* in, word32 inLen, byte* out, word32 outLen,
|
||||||
|
|
Loading…
Reference in New Issue