diff options
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/Makefile.am | 9 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_math.c | 8 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_sha.c | 40 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_sha.h | 24 |
4 files changed, 74 insertions, 7 deletions
diff --git a/3rd_party/libsrp6a-sha512/Makefile.am b/3rd_party/libsrp6a-sha512/Makefile.am index c349d8c..2acd582 100644 --- a/3rd_party/libsrp6a-sha512/Makefile.am +++ b/3rd_party/libsrp6a-sha512/Makefile.am | |||
| @@ -24,7 +24,8 @@ libsrp6a_sha512_la_SOURCES = \ | |||
| 24 | t_conv.c t_math.c t_misc.c \ | 24 | t_conv.c t_math.c t_misc.c \ |
| 25 | t_truerand.c cstr.c \ | 25 | t_truerand.c cstr.c \ |
| 26 | srp.c srp6a_sha512_client.c \ | 26 | srp.c srp6a_sha512_client.c \ |
| 27 | srp.h srp_aux.h cstr.h | 27 | srp.h srp_aux.h cstr.h \ |
| 28 | if !HAVE_OPENSSL | 28 | t_sha.c |
| 29 | libsrp6a_sha512_la_SOURCES += t_sha.c | 29 | #if !HAVE_OPENSSL |
| 30 | endif | 30 | #libsrp6a_sha512_la_SOURCES += t_sha.c |
| 31 | #endif | ||
diff --git a/3rd_party/libsrp6a-sha512/t_math.c b/3rd_party/libsrp6a-sha512/t_math.c index 166ee4c..037650e 100644 --- a/3rd_party/libsrp6a-sha512/t_math.c +++ b/3rd_party/libsrp6a-sha512/t_math.c | |||
| @@ -39,11 +39,13 @@ typedef BIGNUM * BigInteger; | |||
| 39 | typedef BN_CTX * BigIntegerCtx; | 39 | typedef BN_CTX * BigIntegerCtx; |
| 40 | typedef BN_MONT_CTX * BigIntegerModAccel; | 40 | typedef BN_MONT_CTX * BigIntegerModAccel; |
| 41 | #include <limits.h> | 41 | #include <limits.h> |
| 42 | #if OPENSSL_VERSION_NUMBER < 0x30000000L | ||
| 42 | # ifndef OPENSSL_NO_ENGINE | 43 | # ifndef OPENSSL_NO_ENGINE |
| 43 | # define OPENSSL_ENGINE | 44 | # define OPENSSL_ENGINE |
| 44 | # include "openssl/engine.h" | 45 | # include "openssl/engine.h" |
| 45 | static ENGINE * default_engine = NULL; | 46 | static ENGINE * default_engine = NULL; |
| 46 | # endif /* OPENSSL_ENGINE */ | 47 | # endif /* OPENSSL_ENGINE */ |
| 48 | #endif | ||
| 47 | typedef int (*modexp_meth)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 49 | typedef int (*modexp_meth)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
| 48 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *mctx); | 50 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *mctx); |
| 49 | static modexp_meth default_modexp = NULL; | 51 | static modexp_meth default_modexp = NULL; |
| @@ -758,7 +760,11 @@ BigIntegerCheckPrime(BigInteger n, BigIntegerCtx c) | |||
| 758 | if(c == NULL) | 760 | if(c == NULL) |
| 759 | c = ctx = BN_CTX_new(); | 761 | c = ctx = BN_CTX_new(); |
| 760 | #if OPENSSL_VERSION_NUMBER >= 0x00908000 | 762 | #if OPENSSL_VERSION_NUMBER >= 0x00908000 |
| 761 | rv = BN_is_prime_ex(n, 25, c, NULL); | 763 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 764 | rv = BN_check_prime(n, c, NULL); | ||
| 765 | #else | ||
| 766 | rv = BN_is_prime_ex(n, 25, c, NULL); | ||
| 767 | #endif | ||
| 762 | #else | 768 | #else |
| 763 | rv = BN_is_prime(n, 25, NULL, c, NULL); | 769 | rv = BN_is_prime(n, 25, NULL, c, NULL); |
| 764 | #endif | 770 | #endif |
diff --git a/3rd_party/libsrp6a-sha512/t_sha.c b/3rd_party/libsrp6a-sha512/t_sha.c index 4029de8..8e54cb6 100644 --- a/3rd_party/libsrp6a-sha512/t_sha.c +++ b/3rd_party/libsrp6a-sha512/t_sha.c | |||
| @@ -107,6 +107,44 @@ SHA512Final_mbed(unsigned char digest[64], SHA512_CTX * ctx) | |||
| 107 | mbedtls_md_free(ctx); | 107 | mbedtls_md_free(ctx); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | #elif defined(OPENSSL_SHA) | ||
| 111 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
| 112 | void | ||
| 113 | SHA1Init_openssl(SHA1_CTX *ctx) | ||
| 114 | { | ||
| 115 | *ctx = EVP_MD_CTX_new(); | ||
| 116 | EVP_DigestInit(*ctx, EVP_sha1()); | ||
| 117 | } | ||
| 118 | |||
| 119 | void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len) | ||
| 120 | { | ||
| 121 | EVP_DigestUpdate(*ctx, data, (size_t)len); | ||
| 122 | } | ||
| 123 | |||
| 124 | void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx) | ||
| 125 | { | ||
| 126 | EVP_DigestFinal(*ctx, digest, NULL); | ||
| 127 | EVP_MD_CTX_destroy(*ctx); | ||
| 128 | } | ||
| 129 | |||
| 130 | void | ||
| 131 | SHA512Init_openssl(SHA512_CTX *ctx) | ||
| 132 | { | ||
| 133 | *ctx = EVP_MD_CTX_new(); | ||
| 134 | EVP_DigestInit(*ctx, EVP_sha512()); | ||
| 135 | } | ||
| 136 | |||
| 137 | void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len) | ||
| 138 | { | ||
| 139 | EVP_DigestUpdate(*ctx, data, (size_t)len); | ||
| 140 | } | ||
| 141 | |||
| 142 | void SHA512Final_openssl(unsigned char digest[64], SHA512_CTX *ctx) | ||
| 143 | { | ||
| 144 | EVP_DigestFinal(*ctx, digest, NULL); | ||
| 145 | EVP_MD_CTX_destroy(*ctx); | ||
| 146 | } | ||
| 147 | #endif | ||
| 110 | #elif !defined(OPENSSL_SHA) && !defined(TOMCRYPT_SHA) | 148 | #elif !defined(OPENSSL_SHA) && !defined(TOMCRYPT_SHA) |
| 111 | /* Use the free SHA1 if the library doesn't have it */ | 149 | /* Use the free SHA1 if the library doesn't have it */ |
| 112 | 150 | ||
| @@ -273,4 +311,4 @@ unsigned char finalcount[8]; | |||
| 273 | SHA1Transform(context->state, context->buffer); | 311 | SHA1Transform(context->state, context->buffer); |
| 274 | #endif | 312 | #endif |
| 275 | } | 313 | } |
| 276 | #endif /* OPENSSL */ | 314 | #endif |
diff --git a/3rd_party/libsrp6a-sha512/t_sha.h b/3rd_party/libsrp6a-sha512/t_sha.h index 18deec5..2e38067 100644 --- a/3rd_party/libsrp6a-sha512/t_sha.h +++ b/3rd_party/libsrp6a-sha512/t_sha.h | |||
| @@ -38,6 +38,28 @@ | |||
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #ifdef OPENSSL_SHA | 40 | #ifdef OPENSSL_SHA |
| 41 | #include <openssl/err.h> | ||
| 42 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
| 43 | #include <openssl/evp.h> | ||
| 44 | |||
| 45 | typedef EVP_MD_CTX* SHA1_CTX; | ||
| 46 | #define SHA1Init SHA1Init_openssl | ||
| 47 | #define SHA1Update SHA1Update_openssl | ||
| 48 | #define SHA1Final SHA1Final_openssl | ||
| 49 | |||
| 50 | typedef EVP_MD_CTX* SHA512_CTX; | ||
| 51 | #define SHA512Init SHA512Init_openssl | ||
| 52 | #define SHA512Update SHA512Update_openssl | ||
| 53 | #define SHA512Final SHA512Final_openssl | ||
| 54 | |||
| 55 | void SHA1Init_openssl(SHA1_CTX *ctx); | ||
| 56 | void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len); | ||
| 57 | void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx); | ||
| 58 | |||
| 59 | void SHA512Init_openssl(SHA512_CTX *ctx); | ||
| 60 | void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len); | ||
| 61 | void SHA512Final_openssl(unsigned char digest[64], SHA1_CTX *ctx); | ||
| 62 | #else /* for OpenSSL < 3.0 */ | ||
| 41 | #include <openssl/sha.h> | 63 | #include <openssl/sha.h> |
| 42 | 64 | ||
| 43 | typedef SHA_CTX SHA1_CTX; | 65 | typedef SHA_CTX SHA1_CTX; |
| @@ -48,7 +70,7 @@ typedef SHA_CTX SHA1_CTX; | |||
| 48 | #define SHA512Init SHA512_Init | 70 | #define SHA512Init SHA512_Init |
| 49 | #define SHA512Update SHA512_Update | 71 | #define SHA512Update SHA512_Update |
| 50 | #define SHA512Final SHA512_Final | 72 | #define SHA512Final SHA512_Final |
| 51 | 73 | #endif /* for OpenSSL < 3.0 */ | |
| 52 | #elif defined(TOMCRYPT_SHA) | 74 | #elif defined(TOMCRYPT_SHA) |
| 53 | /* mycrypt.h already included above */ | 75 | /* mycrypt.h already included above */ |
| 54 | 76 | ||
