4747import org .bouncycastle .openpgp .operator .PGPSecretKeyDecryptorWithAAD ;
4848import org .bouncycastle .util .Arrays ;
4949import org .bouncycastle .util .BigIntegers ;
50+ import org .bouncycastle .util .Integers ;
5051import org .bouncycastle .util .Strings ;
5152
5253/**
@@ -68,26 +69,26 @@ public SExprParser(PGPDigestCalculatorProvider digestProvider)
6869
6970 private static final Map <Integer , String []> rsaLabels = new HashMap <Integer , String []>()
7071 {{
71- put (ProtectionModeTags .OPENPGP_S2K3_OCB_AES , new String []{"rsa" , "n" , "e" , "protected-at" });
72- put (ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC , new String []{"rsa" , "n" , "e" , "d" , "p" , "q" , "u" , "protected-at" });
72+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_OCB_AES ) , new String []{"rsa" , "n" , "e" , "protected-at" });
73+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC ) , new String []{"rsa" , "n" , "e" , "d" , "p" , "q" , "u" , "protected-at" });
7374 }};
7475 private static final Map <Integer , String []> eccLabels = new HashMap <Integer , String []>()
7576 {{
76- put (ProtectionModeTags .OPENPGP_S2K3_OCB_AES , new String []{"ecc" , "curve" , "flags" , "q" , "protected-at" });
77- put (ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC , new String []{"ecc" , "curve" , "q" , "d" , "protected-at" });
77+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_OCB_AES ) , new String []{"ecc" , "curve" , "flags" , "q" , "protected-at" });
78+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC ) , new String []{"ecc" , "curve" , "q" , "d" , "protected-at" });
7879 }};
7980
8081 private static final Map <Integer , String []> dsaLabels = new HashMap <Integer , String []>()
8182 {{
82- put (ProtectionModeTags .OPENPGP_S2K3_OCB_AES , new String []{"dsa" , "p" , "q" , "g" , "y" , "protected-at" });
83- put (ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC , new String []{"dsa" , "p" , "q" , "g" , "y" , "x" , "protected-at" });
83+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_OCB_AES ) , new String []{"dsa" , "p" , "q" , "g" , "y" , "protected-at" });
84+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC ) , new String []{"dsa" , "p" , "q" , "g" , "y" , "x" , "protected-at" });
8485 }};
8586
8687 private static final Map <Integer , String []> elgLabels = new HashMap <Integer , String []>()
8788 {{
8889 //https://github.com/gpg/gnupg/blob/40227e42ea0f2f1cf9c9f506375446648df17e8d/agent/cvt-openpgp.c#L217
89- put (ProtectionModeTags .OPENPGP_S2K3_OCB_AES , new String []{"elg" , "p" , "q" , "g" , "y" , "protected-at" });
90- put (ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC , new String []{"elg" , "p" , "q" , "g" , "y" , "x" , "protected-at" });
90+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_OCB_AES ) , new String []{"elg" , "p" , "q" , "g" , "y" , "protected-at" });
91+ put (Integers . valueOf ( ProtectionModeTags .OPENPGP_S2K3_SHA1_AES_CBC ) , new String []{"elg" , "p" , "q" , "g" , "y" , "x" , "protected-at" });
9192 }};
9293
9394 private static final String [] rsaBigIntegers = new String []{"n" , "e" };
@@ -402,7 +403,7 @@ private static SecretKeyPacket getSecKeyPacket(PGPPublicKey pubKey, PBEProtectio
402403 {
403404 PGPDigestCalculator digestCalculator = digestProvider .get (HashAlgorithmTags .SHA1 );
404405 OutputStream dOut = digestCalculator .getOutputStream ();
405- byte [] aad = SExpression .buildExpression (expression , keyIn .getExpression (0 ), labels .get (protection )).toCanonicalForm ();
406+ byte [] aad = SExpression .buildExpression (expression , keyIn .getExpression (0 ), ( String []) labels .get (Integers . valueOf ( protection ) )).toCanonicalForm ();
406407 dOut .write (aad );
407408 byte [] check = digestCalculator .getDigest ();
408409 byte [] hashBytes = keyIn .getExpression (1 ).getBytes (2 );
@@ -415,7 +416,7 @@ private static SecretKeyPacket getSecKeyPacket(PGPPublicKey pubKey, PBEProtectio
415416 }
416417 else //ProtectionModeTags.OPENPGP_S2K3_OCB_AES
417418 {
418- String [] filter = labels .get (protection );
419+ String [] filter = ( String []) labels .get (Integers . valueOf ( protection ) );
419420 if (filter == null )
420421 {
421422 // TODO could not get client to generate protected elgamal keys
0 commit comments