public-key: Add optional parameters argument to verify() method
This commit is contained in:
@@ -194,7 +194,7 @@ end:
|
||||
}
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_bliss_public_key_t *this, signature_scheme_t scheme,
|
||||
private_bliss_public_key_t *this, signature_scheme_t scheme, void *params,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
|
||||
@@ -120,7 +120,7 @@ START_TEST(test_bliss_sign_all)
|
||||
{
|
||||
ck_assert(privkey->sign(privkey, signature_scheme, msg,
|
||||
&signature));
|
||||
ck_assert(pubkey->verify(pubkey, signature_scheme, msg,
|
||||
ck_assert(pubkey->verify(pubkey, signature_scheme, NULL, msg,
|
||||
signature));
|
||||
free(signature.ptr);
|
||||
}
|
||||
@@ -179,11 +179,11 @@ START_TEST(test_bliss_sign_fail)
|
||||
ck_assert(privkey->sign(privkey, SIGN_BLISS_WITH_SHA2_512, msg, &signature));
|
||||
|
||||
/* verify with invalid signature scheme */
|
||||
ck_assert(!pubkey->verify(pubkey, SIGN_UNKNOWN, msg, signature));
|
||||
ck_assert(!pubkey->verify(pubkey, SIGN_UNKNOWN, NULL, msg, signature));
|
||||
|
||||
/* corrupt signature */
|
||||
signature.ptr[signature.len - 1] ^= 0x80;
|
||||
ck_assert(!pubkey->verify(pubkey, SIGN_BLISS_WITH_SHA2_512, msg, signature));
|
||||
ck_assert(!pubkey->verify(pubkey, SIGN_BLISS_WITH_SHA2_512, NULL, msg, signature));
|
||||
|
||||
free(signature.ptr);
|
||||
privkey->destroy(privkey);
|
||||
|
||||
@@ -50,7 +50,7 @@ METHOD(public_key_t, get_type, key_type_t,
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_curve25519_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
void *params, chunk_t data, chunk_t signature)
|
||||
{
|
||||
hasher_t *hasher;
|
||||
uint8_t d = 0, k[HASH_SIZE_SHA512], r[32], *sig;
|
||||
|
||||
@@ -167,7 +167,7 @@ METHOD(public_key_t, get_type, key_type_t,
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_gcrypt_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
void *params, chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
{
|
||||
|
||||
@@ -290,7 +290,7 @@ METHOD(public_key_t, get_type, key_type_t,
|
||||
}
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
private_gmp_rsa_public_key_t *this, signature_scheme_t scheme, void *params,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
|
||||
@@ -332,7 +332,8 @@ METHOD(certificate_t, issued_by, bool,
|
||||
tbs = openssl_i2chunk(X509_CRL_INFO, this->crl->crl);
|
||||
#endif
|
||||
X509_CRL_get0_signature(this->crl, &sig, NULL);
|
||||
valid = key->verify(key, this->scheme, tbs, openssl_asn1_str2chunk(sig));
|
||||
valid = key->verify(key, this->scheme, NULL, tbs,
|
||||
openssl_asn1_str2chunk(sig));
|
||||
free(tbs.ptr);
|
||||
key->destroy(key);
|
||||
if (valid && scheme)
|
||||
|
||||
@@ -151,7 +151,7 @@ METHOD(public_key_t, get_type, key_type_t,
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_openssl_ec_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
void *params, chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
{
|
||||
|
||||
@@ -256,7 +256,7 @@ static auth_cfg_t *verify_signature(CMS_SignerInfo *si, int hash_oid)
|
||||
key = cert->get_public_key(cert);
|
||||
if (key)
|
||||
{
|
||||
if (key->verify(key, signature_scheme_from_oid(hash_oid),
|
||||
if (key->verify(key, signature_scheme_from_oid(hash_oid), NULL,
|
||||
attrs, sig))
|
||||
{
|
||||
found = auth->clone(auth);
|
||||
|
||||
@@ -137,7 +137,7 @@ METHOD(public_key_t, get_type, key_type_t,
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_openssl_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
void *params, chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
{
|
||||
|
||||
@@ -430,7 +430,8 @@ METHOD(certificate_t, issued_by, bool,
|
||||
tbs = openssl_i2chunk(X509_CINF, this->x509->cert_info);
|
||||
#endif
|
||||
X509_get0_signature(&sig, NULL, this->x509);
|
||||
valid = key->verify(key, this->scheme, tbs, openssl_asn1_str2chunk(sig));
|
||||
valid = key->verify(key, this->scheme, NULL, tbs,
|
||||
openssl_asn1_str2chunk(sig));
|
||||
free(tbs.ptr);
|
||||
key->destroy(key);
|
||||
if (valid && scheme)
|
||||
|
||||
@@ -201,7 +201,7 @@ METHOD(public_key_t, get_keysize, int,
|
||||
}
|
||||
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_pkcs11_public_key_t *this, signature_scheme_t scheme,
|
||||
private_pkcs11_public_key_t *this, signature_scheme_t scheme, void *params,
|
||||
chunk_t data, chunk_t sig)
|
||||
{
|
||||
CK_MECHANISM_PTR mechanism;
|
||||
|
||||
@@ -227,7 +227,8 @@ METHOD(enumerator_t, enumerate, bool,
|
||||
if (key)
|
||||
{
|
||||
chunk = info->attributes->get_encoding(info->attributes);
|
||||
if (key->verify(key, scheme, chunk, info->encrypted_digest))
|
||||
if (key->verify(key, scheme, NULL, chunk,
|
||||
info->encrypted_digest))
|
||||
{
|
||||
this->auth = auth->clone(auth);
|
||||
key->destroy(key);
|
||||
|
||||
@@ -933,7 +933,8 @@ METHOD(certificate_t, issued_by, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
valid = key->verify(key, scheme, this->certificateInfo, this->signature);
|
||||
valid = key->verify(key, scheme, NULL, this->certificateInfo,
|
||||
this->signature);
|
||||
key->destroy(key);
|
||||
if (valid && schemep)
|
||||
{
|
||||
|
||||
@@ -1719,7 +1719,8 @@ METHOD(certificate_t, issued_by, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
valid = key->verify(key, scheme, this->tbsCertificate, this->signature);
|
||||
valid = key->verify(key, scheme, NULL, this->tbsCertificate,
|
||||
this->signature);
|
||||
key->destroy(key);
|
||||
if (valid && schemep)
|
||||
{
|
||||
|
||||
@@ -502,7 +502,7 @@ METHOD(certificate_t, issued_by, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
valid = key->verify(key, scheme, this->tbsCertList, this->signature);
|
||||
valid = key->verify(key, scheme, NULL, this->tbsCertList, this->signature);
|
||||
key->destroy(key);
|
||||
if (valid && schemep)
|
||||
{
|
||||
|
||||
@@ -753,7 +753,8 @@ METHOD(certificate_t, issued_by, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
valid = key->verify(key, scheme, this->tbsResponseData, this->signature);
|
||||
valid = key->verify(key, scheme, NULL, this->tbsResponseData,
|
||||
this->signature);
|
||||
key->destroy(key);
|
||||
if (valid && schemep)
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ METHOD(certificate_t, issued_by, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
valid = key->verify(key, scheme, this->certificationRequestInfo,
|
||||
valid = key->verify(key, scheme, NULL, this->certificationRequestInfo,
|
||||
this->signature);
|
||||
if (valid && schemep)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user