Skip to content

Commit 48f8b81

Browse files
committed
ECC: increase k-value quality
Also create a random k-value for the non-deterministic case as this number will be hashed with an internally CPACF-created number and therefore increases quality. No need to care about retries here. Signed-off-by: Joerg Schmidbauer <jschmidb@de.ibm.com>
1 parent 3ff87df commit 48f8b81

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/s390_ecc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,9 +1754,15 @@ struct { \
17541754
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
17551755
} while ((rc != 0) && (++counter < MAX_KDSA_RETRIES));
17561756
} else {
1757+
/* Also create a random k-value for the non-deterministic
1758+
* case as this number will be hashed with an internally
1759+
* CPACF-created number and therefore increases quality.
1760+
* Same below for p384 and p521. */
1761+
RAND_bytes(param.P256.rand + off, sizeof(param.P256.rand) - off);
17571762
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
17581763
}
17591764
#else
1765+
RAND_bytes(param.P256.rand + off, sizeof(param.P256.rand) - off);
17601766
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
17611767
#endif
17621768
} else {
@@ -1805,9 +1811,11 @@ struct { \
18051811
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18061812
} while ((rc != 0) && (++counter < MAX_KDSA_RETRIES));
18071813
} else {
1814+
RAND_bytes(param.P384.rand + off, sizeof(param.P384.rand) - off);
18081815
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18091816
}
18101817
#else
1818+
RAND_bytes(param.P384.rand + off, sizeof(param.P384.rand) - off);
18111819
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18121820
#endif
18131821
} else {
@@ -1867,9 +1875,11 @@ struct { \
18671875
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18681876
} while ((rc != 0) && (++counter < MAX_KDSA_RETRIES));
18691877
} else {
1878+
RAND_bytes(param.P521.rand + off, sizeof(param.P521.rand) - off);
18701879
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18711880
}
18721881
#else
1882+
RAND_bytes(param.P521.rand + off, sizeof(param.P521.rand) - off);
18731883
rc = s390_kdsa(fc, param.buff, NULL, 0) ? EIO : 0;
18741884
#endif
18751885
} else {

0 commit comments

Comments
 (0)