bitstorm commented on a change in pull request #462:
URL: https://github.com/apache/wicket/pull/462#discussion_r593763080



##########
File path: wicket-util/src/main/java/org/apache/wicket/util/crypt/AESCrypt.java
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.crypt;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * AES based {@link ICrypt} encrypt and decrypt strings such as passwords or 
URL segments.
+ * Based on http://stackoverflow.com/a/992413
+ * 
+ * @see ICrypt
+ */
+class AESCrypt extends AbstractJceCrypt
+{
+
+       private final SecretKey secretKey;
+       private final String algorithm;
+       private final int ivSize;
+
+       
+       /**
+        * Constructor
+        * 
+        * @param secretKey
+        *              The {@link SecretKey} to use to initialize the {@link 
Cipher}.
+        */
+       public AESCrypt(SecretKey secretKey)
+       {
+               this(secretKey, "AES/CBC/PKCS5Padding", 16);
+       }
+
+       /**
+        * Constructor
+        * 
+        * @param secretKey
+        *              The {@link SecretKey} to use to initialize the {@link 
Cipher}.
+        * @param algorithm
+        *              The cipher algorithm to use, for example 
"AES/CBC/PKCS5Padding".
+        * @param ivSize
+        *              The size of the Initialization Vector to use with the 
cipher.

Review comment:
       Right, but during decipher phase you need ivSize before creating the 
cipher reading the first ivSize of encrypted data. So I would leave this 
constructor parameter  




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to