Fix weak cryptography issues 13/119013/1 2.3.2
authorMalarvizhi <malarvizhi.44@wipro.com>
Wed, 10 Mar 2021 07:27:01 +0000 (23:27 -0800)
committerMalarvizhi <malarvizhi.44@wipro.com>
Wed, 10 Mar 2021 07:27:01 +0000 (23:27 -0800)
Issue-ID: OPTFRA-927
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: I2ae9a114b9825c3d3e6faa31afb72a54cdf0c423

18 files changed:
cmso-database/pom.xml
cmso-logger/pom.xml
cmso-optimizer/pom.xml
cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/PropertiesManagement.java
cmso-optimizer/src/main/resources/META-INF/resources/swagger/swagger.json
cmso-robot/pom.xml
cmso-service/pom.xml
cmso-service/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java
cmso-service/src/main/resources/META-INF/resources/swagger/swagger.json
cmso-sonar/pom.xml
cmso-ticketmgt/pom.xml
cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java
cmso-ticketmgt/src/main/resources/META-INF/resources/swagger/swagger.json
cmso-topology/pom.xml
cmso-topology/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java
cmso-topology/src/main/resources/META-INF/resources/swagger/swagger.json
pom.xml
version.properties

index c576d1f..190845e 100644 (file)
@@ -36,7 +36,7 @@
     <parent>\r
         <groupId>org.onap.optf.cmso</groupId>\r
         <artifactId>cmso</artifactId>\r
-        <version>2.3.1-SNAPSHOT</version>\r
+        <version>2.3.2-SNAPSHOT</version>\r
     </parent>\r
 \r
        <groupId>org.onap.optf.cmso</groupId>\r
index 0079f6f..d857eb2 100644 (file)
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>cmso</artifactId>
         <groupId>org.onap.optf.cmso</groupId>
-        <version>2.3.1-SNAPSHOT</version>
+        <version>2.3.2-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
index 32a5546..1cca4ad 100644 (file)
@@ -19,7 +19,7 @@
        <parent>
                <groupId>org.onap.optf.cmso</groupId>
                <artifactId>cmso</artifactId>
-               <version>2.3.1-SNAPSHOT</version>
+               <version>2.3.2-SNAPSHOT</version>
        </parent>
 
        <groupId>org.onap.optf.cmso.optimizer</groupId>
index 12da757..6bf0ee8 100644 (file)
@@ -35,7 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
-
+import java.security.SecureRandom;
 /**
  * The Class PropertiesManagement.
  */
@@ -47,14 +47,15 @@ public class PropertiesManagement {
 
     private static final String algorithm = "AES";
 
-    private static final String cipherMode = "CBC";
+    private static final String cipherMode = "GCM";
 
-    private static final String paddingScheme = "PKCS5Padding";
+    private static final String paddingScheme = "NoPadding";
 
     private static final String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme;
 
-    private static final String initVector = "ONAPCMSOVECTORIV"; // 16 bytes IV
-
+    private static final SecureRandom random = new SecureRandom();
+   
+    
     @Autowired
     Environment env;
 
@@ -80,7 +81,7 @@ public class PropertiesManagement {
     public static String getDecryptedValue(String value) {
         if (value.startsWith("enc:")) {
             String secret = getSecret();
-            value = decrypt(secret, initVector, value.substring(4));
+            value = decrypt(secret, value.substring(4));
         }
         return value;
     }
@@ -93,13 +94,16 @@ public class PropertiesManagement {
      */
     public static String getEncryptedValue(String value) {
         String secret = getSecret();
-        value = encrypt(secret, initVector, value);
+        value = encrypt(secret, value);
         return value;
     }
 
-    private static final String encrypt(String key, String initVector, String value) {
+    private static final String encrypt(String key, String value) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+
+           byte[] bytesIV = new byte[16];
+           random.nextBytes(bytesIV);
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
@@ -113,9 +117,11 @@ public class PropertiesManagement {
         return null;
     }
 
-    private static final String decrypt(String key, String initVector, String encrypted) {
+    private static final String decrypt(String key, String encrypted) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+           byte[] bytesIV = new byte[16];
+            random.nextBytes(bytesIV);
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
index cdac14e..f260bb1 100644 (file)
@@ -1,7 +1,7 @@
 {
   "swagger" : "2.0",
   "info" : {
-    "version" : "2.3.0-SNAPSHOT",
+    "version" : "2.3.1-SNAPSHOT",
     "title" : "cmso-optimizer"
   },
   "basePath" : "/optimizer",
index b9a06bd..4fd1e6a 100644 (file)
@@ -24,7 +24,7 @@
        <parent>\r
                <groupId>org.onap.optf.cmso</groupId>\r
                <artifactId>cmso</artifactId>\r
-               <version>2.3.1-SNAPSHOT</version>\r
+               <version>2.3.2-SNAPSHOT</version>\r
        </parent>\r
 \r
        <groupId>org.onap.optf.cmso</groupId>\r
index 37be396..c642a59 100644 (file)
@@ -30,7 +30,7 @@
        <parent>\r
                <groupId>org.onap.optf.cmso</groupId>\r
                <artifactId>cmso</artifactId>\r
-               <version>2.3.1-SNAPSHOT</version>\r
+               <version>2.3.2-SNAPSHOT</version>\r
        </parent>\r
 \r
        <groupId>org.onap.optf.cmso.service</groupId>\r
index b16c52a..3f7a808 100644 (file)
@@ -40,7 +40,7 @@ import javax.crypto.spec.SecretKeySpec;
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.core.env.Environment;\r
 import org.springframework.stereotype.Component;\r
-\r
+import java.security.SecureRandom;\r
 /**\r
  * The Class PropertiesManagement.\r
  */\r
@@ -51,10 +51,10 @@ public class PropertiesManagement {
     private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();\r
 \r
     private static final String algorithm = "AES";\r
-    private static final String cipherMode = "CBC";\r
-    private static final String paddingScheme = "PKCS5Padding";\r
+    private static final String cipherMode = "GCM";\r
+    private static final String paddingScheme = "NoPadding";\r
     private static final String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme;\r
-    private static final String initVector = "ONAPCMSOVECTORIV"; // 16 bytes IV\r
+    private static final SecureRandom random = new SecureRandom();\r
 \r
     @Autowired\r
     Environment env;\r
@@ -81,7 +81,7 @@ public class PropertiesManagement {
     public static String getDecryptedValue(String value) {\r
         if (value.startsWith("enc:")) {\r
             String secret = getSecret();\r
-            value = decrypt(secret, initVector, value.substring(4));\r
+            value = decrypt(secret, value.substring(4));\r
         }\r
         return value;\r
     }\r
@@ -94,13 +94,15 @@ public class PropertiesManagement {
      */\r
     public static String getEncryptedValue(String value) {\r
         String secret = getSecret();\r
-        value = encrypt(secret, initVector, value);\r
+        value = encrypt(secret, value);\r
         return value;\r
     }\r
 \r
-    private static final String encrypt(String key, String initVector, String value) {\r
+    private static final String encrypt(String key, String value) {\r
         try {\r
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));\r
+           byte[] bytesIV = new byte[16];\r
+            random.nextBytes(bytesIV);\r
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);\r
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");\r
             Cipher cipher = Cipher.getInstance(transformation);\r
             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);\r
@@ -114,9 +116,11 @@ public class PropertiesManagement {
         return null;\r
     }\r
 \r
-    private static final String decrypt(String key, String initVector, String encrypted) {\r
+    private static final String decrypt(String key, String encrypted) {\r
         try {\r
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));\r
+            byte[] bytesIV = new byte[16];\r
+            random.nextBytes(bytesIV);\r
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);\r
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");\r
             Cipher cipher = Cipher.getInstance(transformation);\r
             cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);\r
index 932e117..eb563ad 100644 (file)
@@ -1,7 +1,7 @@
 {
   "swagger" : "2.0",
   "info" : {
-    "version" : "2.3.0-SNAPSHOT",
+    "version" : "2.3.1-SNAPSHOT",
     "title" : "cmso-service"
   },
   "basePath" : "/cmso",
           "format" : "int32",
           "description" : "Maximum number of VNF changes to schedule concurrently"
         },
-        "policyId" : {
-          "type" : "string",
-          "description" : "Name of schedule optimization policy used by the change management cmso optimizer to determine available time slot"
+        "changeWindows" : {
+          "type" : "array",
+          "description" : "Lists of desired change windows to schedule the elements.",
+          "items" : {
+            "$ref" : "#/definitions/Change Window"
+          }
+        },
+        "policies" : {
+          "type" : "array",
+          "description" : "List of the policies to control optimization.",
+          "items" : {
+            "$ref" : "#/definitions/Supported Policy Information"
+          }
         },
-        "vnfDetails" : {
+        "elements" : {
           "type" : "array",
           "description" : "Lists of the VNFs to be changed and the desired change windows",
           "items" : {
-            "$ref" : "#/definitions/VNF Details"
+            "$ref" : "#/definitions/Optimizer Element"
           }
         }
       },
       "properties" : {
         "startTime" : {
           "type" : "string",
-          "description" : "Earliest time that a set of changes may begin."
+          "format" : "date-time",
+          "description" : "Earliest time for which changes may begin."
         },
         "endTime" : {
           "type" : "string",
-          "description" : "Latest time by which all changes must be completed"
+          "format" : "date-time",
+          "description" : "Latest time by which all changes must be completed."
         }
       },
-      "description" : "Time window within which the scheduler optimizer can schedule the changes for the  group of NVFs"
+      "description" : "Time window for which tickets are to returned"
     },
     "CmDetailsMessage" : {
       "type" : "object",
index 6a925de..4b5052b 100644 (file)
@@ -24,7 +24,7 @@
        <parent>\r
                <groupId>org.onap.optf.cmso</groupId>\r
                <artifactId>cmso</artifactId>\r
-               <version>2.3.1-SNAPSHOT</version>\r
+               <version>2.3.2-SNAPSHOT</version>\r
        </parent>\r
 \r
        <groupId>org.onap.optf.cmso.sonar</groupId>\r
index e98e910..922cdad 100644 (file)
@@ -19,7 +19,7 @@
        <parent>
                <groupId>org.onap.optf.cmso</groupId>
                <artifactId>cmso</artifactId>
-               <version>2.3.1-SNAPSHOT</version>
+               <version>2.3.2-SNAPSHOT</version>
        </parent>
 
        <groupId>org.onap.optf.cmso.ticketmgt</groupId>
index 8d739ee..c36a587 100644 (file)
@@ -40,7 +40,7 @@ import javax.crypto.spec.SecretKeySpec;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
-
+import java.security.SecureRandom;
 /**
  * The Class PropertiesManagement.
  */
@@ -51,11 +51,10 @@ public class PropertiesManagement {
     private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
 
     private static final  String algorithm = "AES";
-    private static final  String cipherMode = "CBC";
-    private static final  String paddingScheme = "PKCS5Padding";
+    private static final  String cipherMode = "GCM";
+    private static final  String paddingScheme = "NoPadding";
     private static final  String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme;
-
-    private static final String initVector = "ONAPCMSOVECTORIV"; // 16 bytes IV
+    private static final  SecureRandom random = new SecureRandom();
 
     @Autowired
     Environment env;
@@ -82,7 +81,7 @@ public class PropertiesManagement {
     public static String getDecryptedValue(String value) {
         if (value.startsWith("enc:")) {
             String secret = getSecret();
-            value = decrypt(secret, initVector, value.substring(4));
+            value = decrypt(secret,value.substring(4));
         }
         return value;
     }
@@ -95,13 +94,15 @@ public class PropertiesManagement {
      */
     public static String getEncryptedValue(String value) {
         String secret = getSecret();
-        value = encrypt(secret, initVector, value);
+        value = encrypt(secret, value);
         return value;
     }
 
-    private static final String encrypt(String key, String initVector, String value) {
+    private static final String encrypt(String key, String value) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+           byte[] bytesIV = new byte[16];
+           random.nextBytes(bytesIV);
+           IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
@@ -115,9 +116,12 @@ public class PropertiesManagement {
         return null;
     }
 
-    private static final String decrypt(String key, String initVector, String encrypted) {
+    private static final String decrypt(String key, String encrypted) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+            
+            byte[] bytesIV = new byte[16];
+            random.nextBytes(bytesIV);
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
index 0b4ad51..3cac0bb 100644 (file)
@@ -1,7 +1,7 @@
 {
   "swagger" : "2.0",
   "info" : {
-    "version" : "2.3.0-SNAPSHOT",
+    "version" : "2.3.1-SNAPSHOT",
     "title" : "cmso-ticketmgt"
   },
   "basePath" : "/ticketmgt",
index 9e8853f..ec63f46 100644 (file)
@@ -19,7 +19,7 @@
        <parent>
                <groupId>org.onap.optf.cmso</groupId>
                <artifactId>cmso</artifactId>
-               <version>2.3.1-SNAPSHOT</version>
+               <version>2.3.2-SNAPSHOT</version>
        </parent>
 
        <groupId>org.onap.optf.cmso.topology</groupId>
index fadad45..8af1aea 100644 (file)
@@ -35,6 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
+import java.security.SecureRandom;
 
 @Component
 public class PropertiesManagement {
@@ -43,11 +44,10 @@ public class PropertiesManagement {
     private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
 
     private  static final String algorithm = "AES";
-    private  static final String cipherMode = "CBC";
-    private  static final String paddingScheme = "PKCS5Padding";
+    private  static final String cipherMode = "GCM";
+    private  static final String paddingScheme = "NoPadding";
     private  static final String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme;
-
-    private static final String initVector = "ONAPCMSOVECTORIV"; // 16 bytes IV
+    private  static final SecureRandom random = new SecureRandom();
 
     @Autowired
     Environment env;
@@ -74,7 +74,7 @@ public class PropertiesManagement {
     public static String getDecryptedValue(String value) {
         if (value.startsWith("enc:")) {
             String secret = getSecret();
-            value = decrypt(secret, initVector, value.substring(4));
+            value = decrypt(secret, value.substring(4));
         }
         return value;
     }
@@ -87,13 +87,15 @@ public class PropertiesManagement {
      */
     public static String getEncryptedValue(String value) {
         String secret = getSecret();
-        value = encrypt(secret, initVector, value);
+        value = encrypt(secret, value);
         return value;
     }
 
-    private static final String encrypt(String key, String initVector, String value) {
+    private static final String encrypt(String key, String value) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+           byte[] bytesIV = new byte[16];
+            random.nextBytes(bytesIV);
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
@@ -107,9 +109,11 @@ public class PropertiesManagement {
         return null;
     }
 
-    private static final String decrypt(String key, String initVector, String encrypted) {
+    private static final String decrypt(String key, String encrypted) {
         try {
-            IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
+           byte[] bytesIV = new byte[16];
+            random.nextBytes(bytesIV);
+            IvParameterSpec iv = new IvParameterSpec(bytesIV);
             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
             Cipher cipher = Cipher.getInstance(transformation);
             cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
index 1168133..c6aeba7 100644 (file)
@@ -1,7 +1,7 @@
 {
   "swagger" : "2.0",
   "info" : {
-    "version" : "2.3.0-SNAPSHOT",
+    "version" : "2.3.1-SNAPSHOT",
     "title" : "cmso-topology"
   },
   "basePath" : "/topology",
diff --git a/pom.xml b/pom.xml
index d8dcb2f..2fc9f83 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
 
        <groupId>org.onap.optf.cmso</groupId>
        <artifactId>cmso</artifactId>
-       <version>2.3.1-SNAPSHOT</version>
+       <version>2.3.2-SNAPSHOT</version>
        <packaging>pom</packaging>
        
        <name>optf-cmso</name>
index c1a568d..2af7a4f 100644 (file)
@@ -27,7 +27,7 @@
 
 major=2
 minor=3
-patch=1
+patch=2
 
 base_version=${major}.${minor}.${patch}