mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 18:20:27 +00:00
(mbedtls) Changes to make it compatible with Griffin, pt. 1
This commit is contained in:
parent
d2613d6e89
commit
a1e338827c
8
deps/mbedtls/ctr_drbg.c
vendored
8
deps/mbedtls/ctr_drbg.c
vendored
@ -506,11 +506,11 @@ static const unsigned char nonce_pers_nopr[16] =
|
||||
{ 0x1b, 0x54, 0xb8, 0xff, 0x06, 0x42, 0xbf, 0xf5,
|
||||
0x21, 0xf1, 0x5c, 0x1c, 0x0b, 0x66, 0x5f, 0x3f };
|
||||
|
||||
static const unsigned char result_pr[16] =
|
||||
static const unsigned char ctr_result_pr[16] =
|
||||
{ 0x34, 0x01, 0x16, 0x56, 0xb4, 0x29, 0x00, 0x8f,
|
||||
0x35, 0x63, 0xec, 0xb5, 0xf2, 0x59, 0x07, 0x23 };
|
||||
|
||||
static const unsigned char result_nopr[16] =
|
||||
static const unsigned char ctr_result_nopr[16] =
|
||||
{ 0xa0, 0x54, 0x30, 0x3d, 0x8a, 0x7e, 0xa9, 0x88,
|
||||
0x9d, 0x90, 0x3e, 0x07, 0x7c, 0x6f, 0x21, 0x8f };
|
||||
|
||||
@ -553,7 +553,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
|
||||
mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON );
|
||||
CHK( mbedtls_ctr_drbg_random( &ctx, buf, MBEDTLS_CTR_DRBG_BLOCKSIZE ) );
|
||||
CHK( mbedtls_ctr_drbg_random( &ctx, buf, MBEDTLS_CTR_DRBG_BLOCKSIZE ) );
|
||||
CHK( memcmp( buf, result_pr, MBEDTLS_CTR_DRBG_BLOCKSIZE ) );
|
||||
CHK( memcmp( buf, ctr_result_pr, MBEDTLS_CTR_DRBG_BLOCKSIZE ) );
|
||||
|
||||
mbedtls_ctr_drbg_free( &ctx );
|
||||
|
||||
@ -574,7 +574,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
|
||||
CHK( mbedtls_ctr_drbg_random( &ctx, buf, 16 ) );
|
||||
CHK( mbedtls_ctr_drbg_reseed( &ctx, NULL, 0 ) );
|
||||
CHK( mbedtls_ctr_drbg_random( &ctx, buf, 16 ) );
|
||||
CHK( memcmp( buf, result_nopr, 16 ) );
|
||||
CHK( memcmp( buf, ctr_result_nopr, 16 ) );
|
||||
|
||||
mbedtls_ctr_drbg_free( &ctx );
|
||||
|
||||
|
22
deps/mbedtls/gcm.c
vendored
22
deps/mbedtls/gcm.c
vendored
@ -528,13 +528,13 @@ static const unsigned char gcm_key[MAX_TESTS][32] =
|
||||
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 },
|
||||
};
|
||||
|
||||
static const size_t iv_len[MAX_TESTS] =
|
||||
static const size_t gcm_iv_len[MAX_TESTS] =
|
||||
{ 12, 12, 12, 12, 8, 60 };
|
||||
|
||||
static const int iv_index[MAX_TESTS] =
|
||||
{ 0, 0, 1, 1, 1, 2 };
|
||||
|
||||
static const unsigned char iv[MAX_TESTS][64] =
|
||||
static const unsigned char gcm_iv[MAX_TESTS][64] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00 },
|
||||
@ -550,7 +550,7 @@ static const unsigned char iv[MAX_TESTS][64] =
|
||||
0xa6, 0x37, 0xb3, 0x9b },
|
||||
};
|
||||
|
||||
static const size_t add_len[MAX_TESTS] =
|
||||
static const size_t gcm_add_len[MAX_TESTS] =
|
||||
{ 0, 0, 0, 20, 20, 20 };
|
||||
|
||||
static const int add_index[MAX_TESTS] =
|
||||
@ -757,8 +757,8 @@ int mbedtls_gcm_self_test( int verbose )
|
||||
|
||||
ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT,
|
||||
pt_len[i],
|
||||
iv[iv_index[i]], iv_len[i],
|
||||
additional[add_index[i]], add_len[i],
|
||||
gcm_iv[iv_index[i]], gcm_iv_len[i],
|
||||
additional[add_index[i]], gcm_add_len[i],
|
||||
pt[pt_index[i]], buf, 16, tag_buf );
|
||||
|
||||
if( ret != 0 ||
|
||||
@ -784,8 +784,8 @@ int mbedtls_gcm_self_test( int verbose )
|
||||
|
||||
ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_DECRYPT,
|
||||
pt_len[i],
|
||||
iv[iv_index[i]], iv_len[i],
|
||||
additional[add_index[i]], add_len[i],
|
||||
gcm_iv[iv_index[i]], gcm_iv_len[i],
|
||||
additional[add_index[i]], gcm_add_len[i],
|
||||
ct[j * 6 + i], buf, 16, tag_buf );
|
||||
|
||||
if( ret != 0 ||
|
||||
@ -810,8 +810,8 @@ int mbedtls_gcm_self_test( int verbose )
|
||||
mbedtls_gcm_setkey( &ctx, cipher, gcm_key[key_index[i]], key_len );
|
||||
|
||||
ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_ENCRYPT,
|
||||
iv[iv_index[i]], iv_len[i],
|
||||
additional[add_index[i]], add_len[i] );
|
||||
gcm_iv[iv_index[i]], gcm_iv_len[i],
|
||||
additional[add_index[i]], gcm_add_len[i] );
|
||||
if( ret != 0 )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
@ -877,8 +877,8 @@ int mbedtls_gcm_self_test( int verbose )
|
||||
mbedtls_gcm_setkey( &ctx, cipher, gcm_key[key_index[i]], key_len );
|
||||
|
||||
ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_DECRYPT,
|
||||
iv[iv_index[i]], iv_len[i],
|
||||
additional[add_index[i]], add_len[i] );
|
||||
gcm_iv[iv_index[i]], gcm_iv_len[i],
|
||||
additional[add_index[i]], gcm_add_len[i] );
|
||||
if( ret != 0 )
|
||||
{
|
||||
if( verbose != 0 )
|
||||
|
8
deps/mbedtls/hmac_drbg.c
vendored
8
deps/mbedtls/hmac_drbg.c
vendored
@ -418,7 +418,7 @@ static const unsigned char entropy_pr[] = {
|
||||
0x48, 0xa5, 0x84, 0xfe, 0x69, 0xab, 0x5a, 0xee, 0x42, 0xaa, 0x4d, 0x42,
|
||||
0x17, 0x60, 0x99, 0xd4, 0x5e, 0x13, 0x97, 0xdc, 0x40, 0x4d, 0x86, 0xa3,
|
||||
0x7b, 0xf5, 0x59, 0x54, 0x75, 0x69, 0x51, 0xe4 };
|
||||
static const unsigned char result_pr[OUTPUT_LEN] = {
|
||||
static const unsigned char hmac_result_pr[OUTPUT_LEN] = {
|
||||
0x9a, 0x00, 0xa2, 0xd0, 0x0e, 0xd5, 0x9b, 0xfe, 0x31, 0xec, 0xb1, 0x39,
|
||||
0x9b, 0x60, 0x81, 0x48, 0xd1, 0x96, 0x9d, 0x25, 0x0d, 0x3c, 0x1e, 0x94,
|
||||
0x10, 0x10, 0x98, 0x12, 0x93, 0x25, 0xca, 0xb8, 0xfc, 0xcc, 0x2d, 0x54,
|
||||
@ -433,7 +433,7 @@ static const unsigned char entropy_nopr[] = {
|
||||
0x21, 0xc9, 0x13, 0x83, 0x11, 0x46, 0x73, 0x3a, 0xbf, 0x8c, 0x35, 0xc8,
|
||||
0xc7, 0x21, 0x5b, 0x5b, 0x96, 0xc4, 0x8e, 0x9b, 0x33, 0x8c, 0x74, 0xe3,
|
||||
0xe9, 0x9d, 0xfe, 0xdf };
|
||||
static const unsigned char result_nopr[OUTPUT_LEN] = {
|
||||
static const unsigned char hmac_result_nopr[OUTPUT_LEN] = {
|
||||
0xc6, 0xa1, 0x6a, 0xb8, 0xd4, 0x20, 0x70, 0x6f, 0x0f, 0x34, 0xab, 0x7f,
|
||||
0xec, 0x5a, 0xdc, 0xa9, 0xd8, 0xca, 0x3a, 0x13, 0x3e, 0x15, 0x9c, 0xa6,
|
||||
0xac, 0x43, 0xc6, 0xf8, 0xa2, 0xbe, 0x22, 0x83, 0x4a, 0x4c, 0x0a, 0x0a,
|
||||
@ -484,7 +484,7 @@ int mbedtls_hmac_drbg_self_test( int verbose )
|
||||
mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
|
||||
CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
|
||||
CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
|
||||
CHK( memcmp( buf, result_pr, OUTPUT_LEN ) );
|
||||
CHK( memcmp( buf, hmac_result_pr, OUTPUT_LEN ) );
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
@ -507,7 +507,7 @@ int mbedtls_hmac_drbg_self_test( int verbose )
|
||||
CHK( mbedtls_hmac_drbg_reseed( &ctx, NULL, 0 ) );
|
||||
CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
|
||||
CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
|
||||
CHK( memcmp( buf, result_nopr, OUTPUT_LEN ) );
|
||||
CHK( memcmp( buf, hmac_result_nopr, OUTPUT_LEN ) );
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
4
deps/mbedtls/md5.c
vendored
4
deps/mbedtls/md5.c
vendored
@ -126,9 +126,9 @@ void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64]
|
||||
GET_UINT32_LE( X[13], data, 52 );
|
||||
GET_UINT32_LE( X[14], data, 56 );
|
||||
GET_UINT32_LE( X[15], data, 60 );
|
||||
|
||||
#undef S
|
||||
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
|
||||
|
||||
#undef P
|
||||
#define P(a,b,c,d,k,s,t) \
|
||||
{ \
|
||||
a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
|
||||
|
6
deps/mbedtls/ripemd160.c
vendored
6
deps/mbedtls/ripemd160.c
vendored
@ -135,15 +135,15 @@ void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned c
|
||||
C = Cp = ctx->state[2];
|
||||
D = Dp = ctx->state[3];
|
||||
E = Ep = ctx->state[4];
|
||||
|
||||
#undef F1
|
||||
#define F1( x, y, z ) ( x ^ y ^ z )
|
||||
#define F2( x, y, z ) ( ( x & y ) | ( ~x & z ) )
|
||||
#define F3( x, y, z ) ( ( x | ~y ) ^ z )
|
||||
#define F4( x, y, z ) ( ( x & z ) | ( y & ~z ) )
|
||||
#define F5( x, y, z ) ( x ^ ( y | ~z ) )
|
||||
|
||||
#undef S
|
||||
#define S( x, n ) ( ( x << n ) | ( x >> (32 - n) ) )
|
||||
|
||||
#undef P
|
||||
#define P( a, b, c, d, e, r, s, f, k ) \
|
||||
a += f( b, c, d ) + X[r] + k; \
|
||||
a = S( a, s ) + e; \
|
||||
|
6
deps/mbedtls/sha1.c
vendored
6
deps/mbedtls/sha1.c
vendored
@ -127,16 +127,16 @@ void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[6
|
||||
GET_UINT32_BE( W[13], data, 52 );
|
||||
GET_UINT32_BE( W[14], data, 56 );
|
||||
GET_UINT32_BE( W[15], data, 60 );
|
||||
|
||||
#undef S
|
||||
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
|
||||
|
||||
#undef R
|
||||
#define R(t) \
|
||||
( \
|
||||
temp = W[( t - 3 ) & 0x0F] ^ W[( t - 8 ) & 0x0F] ^ \
|
||||
W[( t - 14 ) & 0x0F] ^ W[ t & 0x0F], \
|
||||
( W[t & 0x0F] = S(temp,1) ) \
|
||||
)
|
||||
|
||||
#undef P
|
||||
#define P(a,b,c,d,e,x) \
|
||||
{ \
|
||||
e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
|
||||
|
14
deps/mbedtls/sha256.c
vendored
14
deps/mbedtls/sha256.c
vendored
@ -150,25 +150,29 @@ static const uint32_t K[] =
|
||||
0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
|
||||
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
|
||||
};
|
||||
|
||||
#undef SHRs
|
||||
#define SHR(x,n) ((x & 0xFFFFFFFF) >> n)
|
||||
#undef ROTR
|
||||
#define ROTR(x,n) (SHR(x,n) | (x << (32 - n)))
|
||||
|
||||
#undef S0
|
||||
#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
|
||||
#undef S1
|
||||
#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
|
||||
|
||||
#undef S2
|
||||
#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
|
||||
#undef S3
|
||||
#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
|
||||
|
||||
#define F0(x,y,z) ((x & y) | (z & (x | y)))
|
||||
#undef F1
|
||||
#define F1(x,y,z) (z ^ (x & (y ^ z)))
|
||||
|
||||
#undef R
|
||||
#define R(t) \
|
||||
( \
|
||||
W[t] = S1(W[t - 2]) + W[t - 7] + \
|
||||
S0(W[t - 15]) + W[t - 16] \
|
||||
)
|
||||
|
||||
#undef P
|
||||
#define P(a,b,c,d,e,f,g,h,x,K) \
|
||||
{ \
|
||||
temp1 = h + S3(e) + F1(e,f,g) + K + x; \
|
||||
|
9
deps/mbedtls/sha512.c
vendored
9
deps/mbedtls/sha512.c
vendored
@ -198,14 +198,17 @@ void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char da
|
||||
int i;
|
||||
uint64_t temp1, temp2, W[80];
|
||||
uint64_t A, B, C, D, E, F, G, H;
|
||||
|
||||
#undef SHR
|
||||
#define SHR(x,n) (x >> n)
|
||||
#undef ROTR
|
||||
#define ROTR(x,n) (SHR(x,n) | (x << (64 - n)))
|
||||
|
||||
#undef S0
|
||||
#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))
|
||||
#undef S1
|
||||
#define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6))
|
||||
|
||||
#undef S2
|
||||
#define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))
|
||||
#undef S3
|
||||
#define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))
|
||||
|
||||
#define F0(x,y,z) ((x & y) | (z & (x | y)))
|
||||
|
2
deps/mbedtls/x509_crl.c
vendored
2
deps/mbedtls/x509_crl.c
vendored
@ -570,7 +570,9 @@ int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path )
|
||||
/*
|
||||
* Return an informational string about the certificate.
|
||||
*/
|
||||
#undef BEFORE_COLON
|
||||
#define BEFORE_COLON 14
|
||||
#undef BC
|
||||
#define BC "14"
|
||||
/*
|
||||
* Return an informational string about the CRL.
|
||||
|
2
deps/mbedtls/x509_crt.c
vendored
2
deps/mbedtls/x509_crt.c
vendored
@ -1354,7 +1354,9 @@ static int x509_info_ext_key_usage( char **buf, size_t *size,
|
||||
/*
|
||||
* Return an informational string about the certificate.
|
||||
*/
|
||||
#undef BEFORE_COLON
|
||||
#define BEFORE_COLON 18
|
||||
#undef BC
|
||||
#define BC "18"
|
||||
int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
const mbedtls_x509_crt *crt )
|
||||
|
3
deps/mbedtls/x509_csr.c
vendored
3
deps/mbedtls/x509_csr.c
vendored
@ -328,8 +328,9 @@ int mbedtls_x509_csr_parse_file( mbedtls_x509_csr *csr, const char *path )
|
||||
return( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
#undef BEFORE_COLON
|
||||
#define BEFORE_COLON 14
|
||||
#undef BC
|
||||
#define BC "14"
|
||||
/*
|
||||
* Return an informational string about the CSR.
|
||||
|
Loading…
Reference in New Issue
Block a user