Skip to content

Commit e58d815

Browse files
committed
Ungate constants and gate tests
1 parent 3327d9a commit e58d815

2 files changed

Lines changed: 41 additions & 40 deletions

File tree

tests/test_ciphers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,21 +432,22 @@ def test_rsa_sign_verify(rsa_private, rsa_public):
432432
assert 1024 / 8 == len(signature) == rsa_private.output_size
433433
assert plaintext == rsa_private.verify(signature)
434434

435-
def test_rsa_pss_sign_verify(rsa_private, rsa_public):
436-
plaintext = t2b("Everyone gets Friday off yippee.")
435+
if _lib.RSA_PSS_ENABLED:
436+
def test_rsa_pss_sign_verify(rsa_private, rsa_public):
437+
plaintext = t2b("Everyone gets Friday off yippee.")
437438

438-
# normal usage, sign with private, verify with public
439-
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
439+
# normal usage, sign with private, verify with public
440+
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
440441

441-
assert 1024 / 8 == len(signature) == rsa_private.output_size
442-
assert 0 == rsa_public.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
442+
assert 1024 / 8 == len(signature) == rsa_private.output_size
443+
assert 0 == rsa_public.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
443444

444-
# private object holds both private and public info, so it can also verify
445-
# using the known public key.
446-
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
445+
# private object holds both private and public info, so it can also verify
446+
# using the known public key.
447+
signature = rsa_private.sign_pss(plaintext, HASH_TYPE_SHA256, MGF1SHA256)
447448

448-
assert 1024 / 8 == len(signature) == rsa_private.output_size
449-
assert 0 == rsa_private.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
449+
assert 1024 / 8 == len(signature) == rsa_private.output_size
450+
assert 0 == rsa_private.verify_pss(plaintext, signature, HASH_TYPE_SHA256, MGF1SHA256)
450451

451452
def test_rsa_sign_verify_pem(rsa_private_pem, rsa_public_pem):
452453
plaintext = t2b("Everyone gets Friday off.")

wolfcrypt/_build_ffi.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,34 @@ def generate_libwolfssl():
372372

373373
if RSA_ENABLED:
374374
_cdef += """
375+
static const int WC_RSA_PKCSV15_PAD;
376+
static const int WC_RSA_OAEP_PAD;
377+
static const int WC_RSA_PSS_PAD;
378+
static const int WC_RSA_NO_PAD;
379+
380+
static const int WC_MGF1NONE;
381+
static const int WC_MGF1SHA1;
382+
static const int WC_MGF1SHA224;
383+
static const int WC_MGF1SHA256;
384+
static const int WC_MGF1SHA384;
385+
static const int WC_MGF1SHA512;
386+
387+
static const int WC_HASH_TYPE_NONE;
388+
static const int WC_HASH_TYPE_MD2;
389+
static const int WC_HASH_TYPE_MD4;
390+
static const int WC_HASH_TYPE_MD5;
391+
static const int WC_HASH_TYPE_SHA;
392+
static const int WC_HASH_TYPE_SHA224;
393+
static const int WC_HASH_TYPE_SHA256;
394+
static const int WC_HASH_TYPE_SHA384;
395+
static const int WC_HASH_TYPE_SHA512;
396+
static const int WC_HASH_TYPE_MD5_SHA;
397+
static const int WC_HASH_TYPE_SHA3_224;
398+
static const int WC_HASH_TYPE_SHA3_256;
399+
static const int WC_HASH_TYPE_SHA3_384;
400+
static const int WC_HASH_TYPE_SHA3_512;
401+
static const int WC_HASH_TYPE_BLAKE2B;
402+
static const int WC_HASH_TYPE_BLAKE2S;
375403
typedef struct {...; } RsaKey;
376404
377405
int wc_InitRsaKey(RsaKey* key, void*);
@@ -392,37 +420,9 @@ def generate_libwolfssl():
392420
byte* out, word32 outLen, RsaKey* key, int type,
393421
enum wc_HashType hash, int mgf, byte* label, word32 labelSz);
394422
"""
423+
395424
if RSA_PSS_ENABLED:
396425
_cdef += """
397-
static const int WC_RSA_PKCSV15_PAD;
398-
static const int WC_RSA_OAEP_PAD;
399-
static const int WC_RSA_PSS_PAD;
400-
static const int WC_RSA_NO_PAD;
401-
402-
static const int WC_MGF1NONE;
403-
static const int WC_MGF1SHA1;
404-
static const int WC_MGF1SHA224;
405-
static const int WC_MGF1SHA256;
406-
static const int WC_MGF1SHA384;
407-
static const int WC_MGF1SHA512;
408-
409-
static const int WC_HASH_TYPE_NONE;
410-
static const int WC_HASH_TYPE_MD2;
411-
static const int WC_HASH_TYPE_MD4;
412-
static const int WC_HASH_TYPE_MD5;
413-
static const int WC_HASH_TYPE_SHA;
414-
static const int WC_HASH_TYPE_SHA224;
415-
static const int WC_HASH_TYPE_SHA256;
416-
static const int WC_HASH_TYPE_SHA384;
417-
static const int WC_HASH_TYPE_SHA512;
418-
static const int WC_HASH_TYPE_MD5_SHA;
419-
static const int WC_HASH_TYPE_SHA3_224;
420-
static const int WC_HASH_TYPE_SHA3_256;
421-
static const int WC_HASH_TYPE_SHA3_384;
422-
static const int WC_HASH_TYPE_SHA3_512;
423-
static const int WC_HASH_TYPE_BLAKE2B;
424-
static const int WC_HASH_TYPE_BLAKE2S;
425-
426426
int wc_RsaPSS_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
427427
enum wc_HashType hash, int mgf, RsaKey* key, WC_RNG* rng);
428428
int wc_RsaPSS_Verify(byte* in, word32 inLen, byte* out, word32 outLen,

0 commit comments

Comments
 (0)