Skip to content

Commit 95b13c9

Browse files
committed
Add warning about fixed IVs being deprecated if that option is chosen.
1 parent f8b1ed5 commit 95b13c9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/org/owasp/esapi/reference/DefaultSecurityConfiguration.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ public static SecurityConfiguration getInstance() {
121121
public static final String CIPHERTEXT_USE_MAC = "Encryptor.CipherText.useMAC";
122122
public static final String PLAINTEXT_OVERWRITE = "Encryptor.PlainText.overwrite";
123123
public static final String IV_TYPE = "Encryptor.ChooseIVMethod";
124+
125+
@Deprecated
124126
public static final String FIXED_IV = "Encryptor.fixedIV";
127+
125128
public static final String COMBINED_CIPHER_MODES = "Encryptor.cipher_modes.combined_modes";
126129
public static final String ADDITIONAL_ALLOWED_CIPHER_MODES = "Encryptor.cipher_modes.additional_allowed";
127130
public static final String KDF_PRF_ALG = "Encryptor.KDF.PRF";
@@ -824,7 +827,10 @@ public boolean overwritePlainText() {
824827
*/
825828
public String getIVType() {
826829
String value = getESAPIProperty(IV_TYPE, "random");
827-
if ( value.equalsIgnoreCase("fixed") || value.equalsIgnoreCase("random") ) {
830+
if ( value.equalsIgnoreCase("random") ) {
831+
return value;
832+
} else if ( value.equalsIgnoreCase("fixed") ) {
833+
logSpecial("WARNING: Property '" + IV_TYPE + "=fixed' is DEPRECATED. It was intended to support legacy applications, but is inherently insecure, especially with any streaming mode. Support for this will be completed dropped next ESAPI minor release (probably 2.3");
828834
return value;
829835
} else if ( value.equalsIgnoreCase("specified") ) {
830836
// This is planned for future implementation where setting
@@ -835,18 +841,19 @@ public String getIVType() {
835841
// that for a given key, any particular IV is *NEVER* reused. For
836842
// now, we will assume that generating a random IV is usually going
837843
// to be sufficient to prevent this.
838-
throw new ConfigurationException("'" + IV_TYPE + "=specified' is not yet implemented. Use 'fixed' or 'random'");
844+
throw new ConfigurationException("'" + IV_TYPE + "=specified' is not yet implemented. Use 'random' for now.");
839845
} else {
840846
// TODO: Once 'specified' is legal, adjust exception msg, below.
841847
// DISCUSS: Could just log this and then silently return "random" instead.
842848
throw new ConfigurationException(value + " is illegal value for " + IV_TYPE +
843-
". Use 'random' (preferred) or 'fixed'.");
849+
". Use 'random'.");
844850
}
845851
}
846852

847853
/**
848854
* {@inheritDoc}
849855
*/
856+
@Deprecated
850857
public String getFixedIV() {
851858
if ( getIVType().equalsIgnoreCase("fixed") ) {
852859
String ivAsHex = getESAPIProperty(FIXED_IV, ""); // No default
@@ -858,7 +865,7 @@ public String getFixedIV() {
858865
} else {
859866
// DISCUSS: Should we just log a warning here and return null instead?
860867
// If so, may cause NullPointException somewhere later.
861-
throw new ConfigurationException("IV type not 'fixed' (set to '" +
868+
throw new ConfigurationException("IV type not 'fixed' [which is DEPRECATED!] (set to '" +
862869
getIVType() + "'), so no fixed IV applicable.");
863870
}
864871
}

0 commit comments

Comments
 (0)