Store OID in bigendian notation in pk and sk

This commit is contained in:
Joost Rijneveld 2018-01-30 08:42:22 +00:00
parent c63291fb8e
commit 05dac989c4
Non sono state trovate chiavi note per questa firma nel database
ID Chiave GPG: A4FE39CF49CBC553

16
xmss.c
Vedi File

@ -16,11 +16,11 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk, const uint32_t oid)
return -1;
}
for (i = 0; i < XMSS_OID_LEN; i++) {
pk[i] = (oid >> (8 * i)) & 0xFF;
pk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF;
/* For an implementation that uses runtime parameters, it is crucial
that the OID is part of the secret key as well;
i.e. not just for interoperability, but also for internal use. */
sk[i] = (oid >> (8 * i)) & 0xFF;
sk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF;
}
return xmss_core_keypair(&params, pk + XMSS_OID_LEN, sk + XMSS_OID_LEN);
}
@ -34,7 +34,7 @@ int xmss_sign(unsigned char *sk,
unsigned int i;
for (i = 0; i < XMSS_OID_LEN; i++) {
oid |= sk[i] << (i * 8);
oid |= sk[XMSS_OID_LEN - i - 1] << (i * 8);
}
if (xmss_parse_oid(&params, oid)) {
return -1;
@ -51,7 +51,7 @@ int xmss_sign_open(unsigned char *m, unsigned long long *mlen,
unsigned int i;
for (i = 0; i < XMSS_OID_LEN; i++) {
oid |= pk[i] << (i * 8);
oid |= pk[XMSS_OID_LEN - i - 1] << (i * 8);
}
if (xmss_parse_oid(&params, oid)) {
return -1;
@ -68,8 +68,8 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk, const uint32_t oid)
return -1;
}
for (i = 0; i < XMSS_OID_LEN; i++) {
pk[i] = (oid >> (8 * i)) & 0xFF;
sk[i] = (oid >> (8 * i)) & 0xFF;
pk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF;
sk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF;
}
return xmssmt_core_keypair(&params, pk + XMSS_OID_LEN, sk + XMSS_OID_LEN);
}
@ -83,7 +83,7 @@ int xmssmt_sign(unsigned char *sk,
unsigned int i;
for (i = 0; i < XMSS_OID_LEN; i++) {
oid |= sk[i] << (i * 8);
oid |= sk[XMSS_OID_LEN - i - 1] << (i * 8);
}
if (xmssmt_parse_oid(&params, oid)) {
return -1;
@ -100,7 +100,7 @@ int xmssmt_sign_open(unsigned char *m, unsigned long long *mlen,
unsigned int i;
for (i = 0; i < XMSS_OID_LEN; i++) {
oid |= pk[i] << (i * 8);
oid |= pk[XMSS_OID_LEN - i - 1] << (i * 8);
}
if (xmssmt_parse_oid(&params, oid)) {
return -1;