mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-24 17:16:57 +00:00
Change size of preallocated buffer for pk_sign() calls
This commit is contained in:
parent
9883e899ef
commit
b50c39ca4a
|
@ -49,6 +49,16 @@ static void mbedtls_zeroize( void *v, size_t n ) {
|
|||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* For the currently used signature algorithms the buffer to store any signature
|
||||
* must be at least of size MAX(MBEDTLS_ECDSA_MAX_LEN, MBEDTLS_MPI_MAX_SIZE)
|
||||
*/
|
||||
#if MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_MPI_MAX_SIZE
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
|
||||
#else
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
|
||||
#endif
|
||||
|
||||
void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx )
|
||||
{
|
||||
memset( ctx, 0, sizeof( mbedtls_x509write_cert ) );
|
||||
|
@ -338,7 +348,7 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf,
|
|||
size_t sig_oid_len = 0;
|
||||
unsigned char *c, *c2;
|
||||
unsigned char hash[64];
|
||||
unsigned char sig[MBEDTLS_MPI_MAX_SIZE];
|
||||
unsigned char sig[SIGNATURE_MAX_SIZE];
|
||||
unsigned char tmp_buf[2048];
|
||||
size_t sub_len = 0, pub_len = 0, sig_and_oid_len = 0, sig_len;
|
||||
size_t len = 0;
|
||||
|
|
|
@ -43,11 +43,22 @@
|
|||
#include "mbedtls/pem.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void mbedtls_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* For the currently used signature algorithms the buffer to store any signature
|
||||
* must be at least of size MAX(MBEDTLS_ECDSA_MAX_LEN, MBEDTLS_MPI_MAX_SIZE)
|
||||
*/
|
||||
#if MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_MPI_MAX_SIZE
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
|
||||
#else
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
|
||||
#endif
|
||||
|
||||
void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx )
|
||||
{
|
||||
memset( ctx, 0, sizeof( mbedtls_x509write_csr ) );
|
||||
|
@ -163,7 +174,7 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s
|
|||
size_t sig_oid_len = 0;
|
||||
unsigned char *c, *c2;
|
||||
unsigned char hash[64];
|
||||
unsigned char sig[MBEDTLS_MPI_MAX_SIZE];
|
||||
unsigned char sig[SIGNATURE_MAX_SIZE];
|
||||
unsigned char tmp_buf[2048];
|
||||
size_t pub_len = 0, sig_and_oid_len = 0, sig_len;
|
||||
size_t len = 0;
|
||||
|
|
|
@ -59,6 +59,16 @@ int main( void )
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* For the currently used signature algorithms the buffer to store any signature
|
||||
* must be at least of size MAX(MBEDTLS_ECDSA_MAX_LEN, MBEDTLS_MPI_MAX_SIZE)
|
||||
*/
|
||||
#if MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_MPI_MAX_SIZE
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
|
||||
#else
|
||||
#define SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
|
||||
#endif
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -68,7 +78,7 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
unsigned char hash[32];
|
||||
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
|
||||
unsigned char buf[SIGNATURE_MAX_SIZE];
|
||||
char filename[512];
|
||||
const char *pers = "mbedtls_pk_sign";
|
||||
size_t olen = 0;
|
||||
|
|
Loading…
Reference in a new issue