Remove extra spacings
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
This commit is contained in:
parent
dcf9c96274
commit
c388af63e4
4 changed files with 5 additions and 24 deletions
17
library/pk.c
17
library/pk.c
|
@ -46,13 +46,11 @@
|
|||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/*
|
||||
* Initialise a mbedtls_pk_context
|
||||
*/
|
||||
void mbedtls_pk_init( mbedtls_pk_context *ctx )
|
||||
{
|
||||
|
||||
ctx->pk_info = NULL;
|
||||
ctx->pk_ctx = NULL;
|
||||
}
|
||||
|
@ -395,8 +393,7 @@ int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx,
|
|||
const unsigned char *sig, size_t sig_len,
|
||||
mbedtls_pk_restart_ctx *rs_ctx )
|
||||
{
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) &&
|
||||
hash == NULL )
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) && hash == NULL )
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
|
||||
if( ctx->pk_info == NULL ||
|
||||
|
@ -452,8 +449,7 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
|
|||
const unsigned char *hash, size_t hash_len,
|
||||
const unsigned char *sig, size_t sig_len )
|
||||
{
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) &&
|
||||
hash == NULL )
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) && hash == NULL )
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
|
||||
if( ctx->pk_info == NULL )
|
||||
|
@ -577,12 +573,10 @@ int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx,
|
|||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
|
||||
mbedtls_pk_restart_ctx *rs_ctx )
|
||||
{
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) &&
|
||||
hash == NULL )
|
||||
if( ( md_alg != MBEDTLS_MD_NONE || hash_len != 0 ) && hash == NULL )
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
|
||||
if( ctx->pk_info == NULL ||
|
||||
pk_hashlen_helper( md_alg, &hash_len ) != 0 )
|
||||
if( ctx->pk_info == NULL || pk_hashlen_helper( md_alg, &hash_len ) != 0 )
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
|
@ -695,7 +689,6 @@ int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
|
|||
unsigned char *output, size_t *olen, size_t osize,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
|
||||
{
|
||||
|
||||
if( ctx->pk_info == NULL )
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
|
@ -714,7 +707,6 @@ int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
|
|||
unsigned char *output, size_t *olen, size_t osize,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
|
||||
{
|
||||
|
||||
if( ctx->pk_info == NULL )
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
|
@ -733,7 +725,6 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub,
|
|||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng )
|
||||
{
|
||||
|
||||
if( pub->pk_info == NULL ||
|
||||
prv->pk_info == NULL )
|
||||
{
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
/*
|
||||
* Load all data from a file into a given buffer.
|
||||
|
@ -70,7 +69,6 @@ int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n )
|
|||
FILE *f;
|
||||
long size;
|
||||
|
||||
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_PK_FILE_IO_ERROR );
|
||||
|
||||
|
@ -125,7 +123,6 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
|
|||
size_t n;
|
||||
unsigned char *buf;
|
||||
|
||||
|
||||
if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
|
@ -150,7 +147,6 @@ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path )
|
|||
size_t n;
|
||||
unsigned char *buf;
|
||||
|
||||
|
||||
if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
|
@ -608,7 +604,6 @@ int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end,
|
|||
mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE;
|
||||
const mbedtls_pk_info_t *pk_info;
|
||||
|
||||
|
||||
if( ( ret = mbedtls_asn1_get_tag( p, end, &len,
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
|
||||
{
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
/*
|
||||
* RSAPublicKey ::= SEQUENCE {
|
||||
|
@ -177,7 +176,6 @@ int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start,
|
|||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA )
|
||||
MBEDTLS_ASN1_CHK_ADD( len, pk_write_rsa_pubkey( p, start, mbedtls_pk_rsa( *key ) ) );
|
||||
|
@ -487,7 +485,6 @@ int mbedtls_pk_write_pubkey_pem( const mbedtls_pk_context *key, unsigned char *b
|
|||
unsigned char output_buf[PUB_DER_MAX_BYTES];
|
||||
size_t olen = 0;
|
||||
|
||||
|
||||
if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf,
|
||||
sizeof(output_buf) ) ) < 0 )
|
||||
{
|
||||
|
@ -511,7 +508,6 @@ int mbedtls_pk_write_key_pem( const mbedtls_pk_context *key, unsigned char *buf,
|
|||
const char *begin, *end;
|
||||
size_t olen = 0;
|
||||
|
||||
|
||||
if( ( ret = mbedtls_pk_write_key_der( key, output_buf, sizeof(output_buf) ) ) < 0 )
|
||||
return( ret );
|
||||
|
||||
|
|
|
@ -299,14 +299,13 @@ exit:
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void pk_invalid_param()
|
||||
{
|
||||
mbedtls_pk_context ctx;
|
||||
mbedtls_md_type_t md_alg_none = MBEDTLS_MD_NONE;
|
||||
mbedtls_pk_type_t pk_type = 0;
|
||||
unsigned char buf[] = {0x01,0x02,0x03,0x04,0x05,0x06};
|
||||
unsigned char buf[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
|
||||
size_t buf_size = sizeof( buf );
|
||||
|
||||
mbedtls_pk_init( &ctx );
|
||||
|
|
Loading…
Reference in a new issue