+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.test;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-\r
-import org.junit.Test;\r
-import org.onap.aaf.cadi.CmdLine;\r
-import org.onap.aaf.cadi.Symm;\r
-\r
-import junit.framework.Assert;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-\r
-import org.junit.AfterClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.cadi.CmdLine;\r
-import org.onap.aaf.cadi.Symm;\r
-\r
-import junit.framework.Assert;\r
-\r
-public class JU_Passcode {\r
- @Test\r
- public void test() throws Exception {\r
- int iterations = 0;\r
- long start = System.nanoTime();\r
- int gens= 800, en_de=2000;\r
- for(int j=0;j<gens;++j) {\r
- CmdLine.main(new String[] {"keygen","tempkey"});\r
- \r
- Symm symm;\r
- File fi = new File("tempkey");\r
- Assert.assertEquals(2074, fi.length());\r
- FileInputStream fis = new FileInputStream(fi);\r
- \r
- try {\r
- symm = Symm.obtain(fis);\r
- } finally {\r
- fis.close();\r
- fi.delete();\r
- }\r
- String samples[] = {"activevos","ThisIsATestPassword","I have spaces","I have 's, /s and &s and _s"};\r
- ByteArrayOutputStream baos;\r
- for(int i=0;i<en_de;++i) {\r
- String password = samples[i%samples.length];\r
- baos = new ByteArrayOutputStream();\r
- symm.enpass(password, baos);\r
- String pass = baos.toString();\r
- byte[] array = baos.toByteArray();\r
- for(int k=0;k<array.length;++k) {\r
- byte ch = array[k];\r
-// for(int k=0;k<pass.length();++k) {\r
-// char ch = pass.charAt(k);\r
- if(!(Character.isLetter(ch) || Character.isDigit(ch) || ch=='-' || ch=='_' || ch=='=')) {\r
- throw new Exception("Yikes, have a bad character..." + ch + '(' + (int)ch + ')');\r
- }\r
- }\r
- baos = new ByteArrayOutputStream();\r
- symm.depass(pass, baos);\r
- Assert.assertEquals(password,baos.toString());\r
- Assert.assertEquals(password,symm.depass(pass));\r
- ++iterations;\r
- }\r
- symm.enpass("activevos", System.out);\r
- System.out.println();\r
- }\r
- float ms = (System.nanoTime()-start)/1000000F;\r
- System.out.println("Ran " + iterations + " Encrypt/Decrypt cycles + " + gens + " keygens");\r
-\r
- System.out.println("Total: " + ms + "ms");\r
- System.out.println("Avg: " + ms/iterations + "ms");\r
- System.out.println("Avg Gen + " + en_de + " Encrypt/Decrypt cycles: " + ms/gens + "ms");\r
-\r
-\r
- }\r
- \r
- @AfterClass\r
- public static void tearDown() {\r
- \r
- }\r
-\r
-}\r