File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed
core/src/main/java/org/bouncycastle/pqc/crypto/mlkem Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change 11package org .bouncycastle .pqc .crypto .mlkem ;
22
33import org .bouncycastle .crypto .EncapsulatedSecretExtractor ;
4- import org .bouncycastle .crypto .params .AsymmetricKeyParameter ;
54
65public class MLKEMExtractor
76 implements EncapsulatedSecretExtractor
87{
9- private MLKEMEngine engine ;
8+ private final MLKEMPrivateKeyParameters privateKey ;
9+ private final MLKEMEngine engine ;
1010
11- private MLKEMPrivateKeyParameters key ;
12-
13- public MLKEMExtractor (MLKEMPrivateKeyParameters privParams )
11+ public MLKEMExtractor (MLKEMPrivateKeyParameters privateKey )
1412 {
15- this .key = privParams ;
16- initCipher (privParams );
17- }
13+ if (privateKey == null )
14+ {
15+ throw new NullPointerException ("'privateKey' cannot be null" );
16+ }
1817
19- private void initCipher (AsymmetricKeyParameter recipientKey )
20- {
21- MLKEMPrivateKeyParameters key = (MLKEMPrivateKeyParameters )recipientKey ;
22- engine = key .getParameters ().getEngine ();
18+ this .privateKey = privateKey ;
19+ this .engine = privateKey .getParameters ().getEngine ();
2320 }
2421
25- @ Override
2622 public byte [] extractSecret (byte [] encapsulation )
2723 {
28- // Decryption
29- byte [] sharedSecret = engine .kemDecrypt (key .getEncoded (), encapsulation );
30- return sharedSecret ;
24+ return engine .kemDecrypt (privateKey .getEncoded (), encapsulation );
3125 }
3226
3327 public int getEncapsulationLength ()
You can’t perform that action at this time.
0 commit comments