mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
The below code should fail instead of computing the seal :
byte[] input = "The quick brown fox jumps over the lazy dog".getBytes("UTF-8");
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
kpg.initialize(2048);
Mac mac = Mac.getInstance("HmacSHA256", "BC");
KeyPair kp = kpg.generateKeyPair();
mac.init(kp.getPrivate());
byte[] seal = mac.doFinal(input);
Indeed, according to JCA Reference Guide:
HMAC can be used with any cryptographic hash function, e.g., SHA-256, in combination with a secret shared key
Metadata
Metadata
Assignees
Labels
No labels