Skip to content

Commit 219100b

Browse files
committed
Merge remote-tracking branch 'amxx/feature/RSA' into feature/RSA
2 parents 84ae125 + 28c8271 commit 219100b

File tree

1 file changed

+4
-1
lines changed
  • contracts/utils/cryptography

1 file changed

+4
-1
lines changed

contracts/utils/cryptography/RSA.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ library RSA {
3232
* IMPORTANT: Although this function allows for it, using n of length 1024 bits is considered unsafe.
3333
* Consider using at least 2048 bits.
3434
*
35+
* WARNING: PKCS#1 v1.5 allows for replayability given the message may contain arbitrary optional parameters in the
36+
* DigestInfo. Consider using an onchain nonce or unique identifier to include in the message to prevent replay attacks.
37+
*
3538
* @param digest the digest to verify
3639
* @param s is a buffer containing the signature
3740
* @param e is the exponent of the public key
@@ -48,7 +51,7 @@ library RSA {
4851
return false;
4952
}
5053

51-
// verify that s < n
54+
// Verify that s < n to ensure there's only one valid signature for a given message
5255
for (uint256 i = 0; i < length; i += 0x20) {
5356
uint256 p = Math.min(i, length - 0x20);
5457
bytes32 sp = _unsafeReadBytes32(s, p);

0 commit comments

Comments
 (0)