Store OID in bigendian notation in pk and sk
This commit is contained in:
parent
c63291fb8e
commit
05dac989c4
16
xmss.c
16
xmss.c
@ -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(¶ms, 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(¶ms, 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(¶ms, 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(¶ms, 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(¶ms, 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(¶ms, oid)) {
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user