Skip to content

Commit

Permalink
CryptoUtil.getKeywrapAlgorithmFromOID: Fix DES-EDE3-CBC selection
Browse files Browse the repository at this point in the history
Commit dbd2d9b contained the edit:

-        if (oid.equals(KW_DES_CBC_PAD))
+        if (oid.equals(KeyWrapAlgorithm.DES_CBC_PAD_OID))

KW_DES_CBC_PAD was 1.2.840.113549.3.7 (DES-EDE3-CBC; this definition
was removed in the same commit). But
KeyWrapAlgorithm.DES_CBC_PAD_OID is 1.3.14.3.2.7.  This is a
behaviour change that breaks KRA archival (possibly recovery too).

Test equality to KeyWrapAlgorithm.DES3_CBC_PAD_OID to restore the
correct behaviour.  Also fix a similar error in WrappingParams.java.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1709585
  • Loading branch information
frasertweedale committed Sep 19, 2019
1 parent b035d92 commit c6b5b05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,7 @@ public static KeyWrapAlgorithm getKeyWrapAlgorithmFromOID(String wrapOID) throws
if (oid.equals(KeyWrapAlgorithm.AES_KEY_WRAP_OID))
return KeyWrapAlgorithm.AES_CBC_PAD;

if (oid.equals(KeyWrapAlgorithm.DES_CBC_PAD_OID))
if (oid.equals(KeyWrapAlgorithm.DES3_CBC_PAD_OID))
return KeyWrapAlgorithm.DES3_CBC_PAD;

throw new NoSuchAlgorithmException(wrapOID);
Expand Down
2 changes: 1 addition & 1 deletion base/util/src/netscape/security/util/WrappingParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public WrappingParams(String encryptOID, String wrapName, String priKeyAlgo, IVP
// New clients set this correctly.
// We'll assume the old DES3 wrapping here.
encrypt = EncryptionAlgorithm.DES_CBC_PAD;
} else if (encryptOID.equals(KeyWrapAlgorithm.DES_CBC_PAD_OID.toString())) {
} else if (encryptOID.equals(KeyWrapAlgorithm.DES3_CBC_PAD_OID.toString())) {
encrypt = EncryptionAlgorithm.DES3_CBC_PAD;
} else if (encryptOID.equals(KeyWrapAlgorithm.AES_CBC_PAD_OID.toString())) {
encrypt = EncryptionAlgorithm.AES_128_CBC_PAD;
Expand Down

0 comments on commit c6b5b05

Please sign in to comment.