diff options
-rw-r--r-- | ncr-pk.c | 14 | ||||
-rw-r--r-- | ncr-pk.h | 2 |
2 files changed, 12 insertions, 4 deletions
@@ -349,7 +349,7 @@ int ret; err(); return ret; } - ctx->sign_hash = ret; + ctx->sign_hash = _ncr_algo_to_properties(ret); switch(algo->algo) { case NCR_ALG_RSA: @@ -448,8 +448,12 @@ unsigned long osize = *output_size; switch(ctx->algorithm->algo) { case NCR_ALG_RSA: + if (ctx->sign_hash == NULL) { + err(); + return -EINVAL; + } cret = rsa_sign_hash_ex( input, input_size, output, &osize, - ctx->type, ctx->sign_hash, ctx->salt_len, &ctx->key->key.pk.rsa); + ctx->type, ctx->sign_hash->algo, ctx->salt_len, &ctx->key->key.pk.rsa); if (cret != CRYPT_OK) { err(); @@ -484,8 +488,12 @@ int stat; switch(ctx->algorithm->algo) { case NCR_ALG_RSA: + if (ctx->sign_hash == NULL) { + err(); + return -EINVAL; + } cret = rsa_verify_hash_ex( signature, signature_size, - hash, hash_size, ctx->type, ctx->sign_hash, + hash, hash_size, ctx->type, ctx->sign_hash->algo, ctx->salt_len, &stat, &ctx->key->key.pk.rsa); if (cret != CRYPT_OK) { @@ -6,7 +6,7 @@ struct ncr_pk_ctx { const struct algo_properties_st *algorithm; /* algorithm */ - ncr_algorithm_t sign_hash; /* for verification */ + const struct algo_properties_st *sign_hash; /* for verification */ ncr_algorithm_t oaep_hash; int salt_len; /* for RSA-PSS signatures */ |