crypto/signature: introduce domain seperation

It might seem a bit like unnecessary bikeshedding but it shouldn't hurt
anyone.
cute-signatures
Aydin Mercan 2022-08-10 16:51:22 +03:00
parent dea8ded23e
commit 5b020ec9ef
Signed by: jaiden
SSH Key Fingerprint: SHA256:vy6hjzotbn/MWZAbjzURNk3NL62EPkjoHsJ5xr/s7nk
2 changed files with 14 additions and 0 deletions

View File

@ -314,6 +314,7 @@ void apk_public_key_free(struct apk_public_key *pub)
int apk_verify_digest_start(struct apk_digest_ctx *dctx, uint16_t signature_type)
{
const uint8_t domain_seperator[5] = {'q', 't', 's', 'e', 'p'};
uint8_t digest;
switch (signature_type) {
@ -335,6 +336,12 @@ int apk_verify_digest_start(struct apk_digest_ctx *dctx, uint16_t signature_type
return -APKE_CRYPTO_ERROR;
}
if (signature_type == APK_SIGNATURE_CUTE) {
if (apk_digest_ctx_update(dctx, domain_seperator, 5) != 0) {
return -APKE_CRYPTO_ERROR;
}
}
return 0;
}

View File

@ -311,6 +311,7 @@ void apk_secret_key_free(struct apk_secret_key *sec)
int apk_sign_digest_start(struct apk_digest_ctx *dctx, uint16_t signature_type)
{
const uint8_t domain_seperator[5] = {'q', 't', 's', 'e', 'p'};
uint8_t digest;
switch (signature_type) {
@ -332,6 +333,12 @@ int apk_sign_digest_start(struct apk_digest_ctx *dctx, uint16_t signature_type)
return -APKE_CRYPTO_ERROR;
}
if (signature_type == APK_SIGNATURE_CUTE) {
if (apk_digest_ctx_update(dctx, domain_seperator, 5) != 0) {
return -APKE_CRYPTO_ERROR;
}
}
return 0;
}