Updated Libraries
All checks were successful
Locusworks Team/crypto/pipeline/head This commit looks good

This commit is contained in:
2021-09-14 22:57:25 -05:00
parent f691d69d44
commit eb5035cb11
22 changed files with 228 additions and 91 deletions

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: AES.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: AESKey.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: AESKeySpec.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: EncryptionKeyFactory.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: HashSalt.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: KeyFile.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: RSA.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: SSHEncodedKeySpec.java
*

View File

@ -1,3 +1,30 @@
/*
*
* Project: Crypto, File: ConfigurationCallback.java
*
* Copyright 2019 Locusworks LLC.
* All rights reserved. Federal copyright law prohibits unauthorized reproduction by
* any means and imposes fines up to $25,000 for violation. No part of this material
* may be reproduced, transmitted, transcribed, stored in a retrieval system, copied,
* modified, duplicated, adapted or translated into another program language in any
* form or by any means, electronic, mechanical, photocopying, recording, or
* otherwise, without the prior written permission from Locusworks. Locusworks
* affirms that Crypto(R) software and data is subject to United States
* Government Purpose Rights. Contact Locusworks, 1313 Lawnview Drive
* Forney TX 75126, (802) 488-0438, for commercial licensing opportunities.
*
* IN NO EVENT SHALL LOCUSWORKS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF LOCUSWORKS HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NO RESPONSIBILITY IS ASSUMED BY
* LOCUSWORKS FOR ITS USE, OR FOR ANY INFRINGEMENTS OF PATENTS OR OTHER RIGHTS OF
* THIRD PARTIES RESULTING FROM ITS USE. LOCUSWORKS SPECIFICALLY DISCLAIMS ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND
* ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". LOCUSWORKS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*/
package net.locusworks.crypto.configuration;
@FunctionalInterface

View File

@ -1,3 +1,30 @@
/*
*
* Project: Crypto, File: ConfigurationManager.java
*
* Copyright 2019 Locusworks LLC.
* All rights reserved. Federal copyright law prohibits unauthorized reproduction by
* any means and imposes fines up to $25,000 for violation. No part of this material
* may be reproduced, transmitted, transcribed, stored in a retrieval system, copied,
* modified, duplicated, adapted or translated into another program language in any
* form or by any means, electronic, mechanical, photocopying, recording, or
* otherwise, without the prior written permission from Locusworks. Locusworks
* affirms that Crypto(R) software and data is subject to United States
* Government Purpose Rights. Contact Locusworks, 1313 Lawnview Drive
* Forney TX 75126, (802) 488-0438, for commercial licensing opportunities.
*
* IN NO EVENT SHALL LOCUSWORKS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF LOCUSWORKS HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NO RESPONSIBILITY IS ASSUMED BY
* LOCUSWORKS FOR ITS USE, OR FOR ANY INFRINGEMENTS OF PATENTS OR OTHER RIGHTS OF
* THIRD PARTIES RESULTING FROM ITS USE. LOCUSWORKS SPECIFICALLY DISCLAIMS ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND
* ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". LOCUSWORKS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*/
package net.locusworks.crypto.configuration;
import java.io.IOException;

View File

@ -1,3 +1,30 @@
/*
*
* Project: Crypto, File: PersistableRequest.java
*
* Copyright 2019 Locusworks LLC.
* All rights reserved. Federal copyright law prohibits unauthorized reproduction by
* any means and imposes fines up to $25,000 for violation. No part of this material
* may be reproduced, transmitted, transcribed, stored in a retrieval system, copied,
* modified, duplicated, adapted or translated into another program language in any
* form or by any means, electronic, mechanical, photocopying, recording, or
* otherwise, without the prior written permission from Locusworks. Locusworks
* affirms that Crypto(R) software and data is subject to United States
* Government Purpose Rights. Contact Locusworks, 1313 Lawnview Drive
* Forney TX 75126, (802) 488-0438, for commercial licensing opportunities.
*
* IN NO EVENT SHALL LOCUSWORKS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF LOCUSWORKS HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NO RESPONSIBILITY IS ASSUMED BY
* LOCUSWORKS FOR ITS USE, OR FOR ANY INFRINGEMENTS OF PATENTS OR OTHER RIGHTS OF
* THIRD PARTIES RESULTING FROM ITS USE. LOCUSWORKS SPECIFICALLY DISCLAIMS ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND
* ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". LOCUSWORKS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*/
package net.locusworks.crypto.configuration;
public interface PersistableRequest {

View File

@ -1,3 +1,30 @@
/*
*
* Project: Crypto, File: PropertiesManager.java
*
* Copyright 2019 Locusworks LLC.
* All rights reserved. Federal copyright law prohibits unauthorized reproduction by
* any means and imposes fines up to $25,000 for violation. No part of this material
* may be reproduced, transmitted, transcribed, stored in a retrieval system, copied,
* modified, duplicated, adapted or translated into another program language in any
* form or by any means, electronic, mechanical, photocopying, recording, or
* otherwise, without the prior written permission from Locusworks. Locusworks
* affirms that Crypto(R) software and data is subject to United States
* Government Purpose Rights. Contact Locusworks, 1313 Lawnview Drive
* Forney TX 75126, (802) 488-0438, for commercial licensing opportunities.
*
* IN NO EVENT SHALL LOCUSWORKS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF LOCUSWORKS HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NO RESPONSIBILITY IS ASSUMED BY
* LOCUSWORKS FOR ITS USE, OR FOR ANY INFRINGEMENTS OF PATENTS OR OTHER RIGHTS OF
* THIRD PARTIES RESULTING FROM ITS USE. LOCUSWORKS SPECIFICALLY DISCLAIMS ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND
* ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". LOCUSWORKS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*/
package net.locusworks.crypto.configuration;
import java.io.BufferedReader;

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: package-info.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: DataOutputStreamHelper.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: HashUtils.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: RandomString.java
*

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: AESEncryptionTest.java
*
@ -28,8 +28,8 @@
package net.locusworks.crypto.tests;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import net.locusworks.crypto.AES;
@ -39,10 +39,10 @@ public class AESEncryptionTest {
public void testEncryption() {
try {
String encrypted = AES.createInstance().encrypt("hello world");
Assert.assertTrue(String.format("Encrypted String is not blank? :%s", encrypted), !StringUtils.isBlank(encrypted));
assertTrue(StringUtils.isNotBlank(encrypted), String.format("Encrypted String is not blank? :%s", encrypted));
} catch (Exception ex) {
ex.printStackTrace(System.err);
Assert.fail();
fail();
}
}
@ -52,16 +52,18 @@ public class AESEncryptionTest {
try {
AES aes = AES.createInstance();
String encrypted = aes.encrypt(testString);
Assert.assertTrue(String.format("Encrypted String is not blank? :%s", encrypted), !StringUtils.isBlank(encrypted));
assertTrue(StringUtils.isNotBlank(encrypted), String.format("Encrypted String is not blank? :%s", encrypted));
String decrypted = aes.decrypt(encrypted);
Assert.assertTrue(String.format("Decrypted String is not blank? :%s", decrypted), !StringUtils.isBlank(encrypted));
Assert.assertTrue("Test String and Original String the same? :%s", testString.equals(decrypted));
assertTrue(StringUtils.isNotBlank(encrypted), String.format("Decrypted String is not blank? :%s", decrypted));
boolean same = testString.equals(decrypted);
assertTrue(same, String.format("Test String and Original String the same? :%s", same));
} catch (Exception ex) {
ex.printStackTrace(System.err);
Assert.fail();
fail();
}
}

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: HashSaltTest.java
*
@ -28,35 +28,35 @@
package net.locusworks.crypto.tests;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import net.locusworks.crypto.HashSalt;
public class HashSaltTest {
private static String samplePassword="Hello World";
@Test
public void testEncryption() {
try {
String hashSalt = HashSalt.createHash(samplePassword);
Assert.assertTrue(String.format("Encrypted String is not blank? :%s", hashSalt), !StringUtils.isBlank(hashSalt));
} catch(Exception ex) {
Assert.fail();
}
}
@Test
public void testDecryption() {
try {
String hashSalt = HashSalt.createHash(samplePassword);
boolean decrypted = HashSalt.validatePassword(samplePassword, hashSalt);
Assert.assertTrue("Test String and Original String the same? :%s", decrypted);
} catch(Exception ex) {
Assert.fail();
}
}
private static String samplePassword="Hello World";
@Test
public void testEncryption() {
try {
String hashSalt = HashSalt.createHash(samplePassword);
assertTrue(StringUtils.isNotBlank(hashSalt), String.format("Encrypted String is not blank? :%s", hashSalt));
} catch(Exception ex) {
fail();
}
}
@Test
public void testDecryption() {
try {
String hashSalt = HashSalt.createHash(samplePassword);
boolean decrypted = HashSalt.validatePassword(samplePassword, hashSalt);
assertTrue(decrypted, String.format("Test String and Original String the same? :%s", decrypted));
} catch(Exception ex) {
fail();
}
}
}

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: HashUtilsTest.java
*
@ -27,38 +27,38 @@
*/
package net.locusworks.crypto.tests;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;
import net.locusworks.crypto.utils.HashUtils;
public class HashUtilsTest {
private static final String TEST_STRING = "Hello World";
@Test
public void testMD5() throws Exception {
String digestUtilsMD5 = DigestUtils.md5Hex(TEST_STRING.getBytes());
String hashUtilsMD5 = HashUtils.hash("MD5", TEST_STRING);
assertTrue(digestUtilsMD5.equals(hashUtilsMD5));
}
@Test
public void testSHA1() throws Exception {
String digestUtilsMD5 = DigestUtils.sha1Hex(TEST_STRING.getBytes());
String hashUtilsMD5 = HashUtils.hash("SHA-1", TEST_STRING);
assertTrue(digestUtilsMD5.equals(hashUtilsMD5));
}
@Test
public void testSHA512() throws Exception {
String digestUtilsMD5 = DigestUtils.sha512Hex(TEST_STRING.getBytes());
String hashUtilsMD5 = HashUtils.hash("SHA-512", TEST_STRING);
assertTrue(digestUtilsMD5.equals(hashUtilsMD5));
}

View File

@ -1,6 +1,35 @@
/*
*
* Project: Crypto, File: PropertiesManagerTest.java
*
* Copyright 2019 Locusworks LLC.
* All rights reserved. Federal copyright law prohibits unauthorized reproduction by
* any means and imposes fines up to $25,000 for violation. No part of this material
* may be reproduced, transmitted, transcribed, stored in a retrieval system, copied,
* modified, duplicated, adapted or translated into another program language in any
* form or by any means, electronic, mechanical, photocopying, recording, or
* otherwise, without the prior written permission from Locusworks. Locusworks
* affirms that Crypto(R) software and data is subject to United States
* Government Purpose Rights. Contact Locusworks, 1313 Lawnview Drive
* Forney TX 75126, (802) 488-0438, for commercial licensing opportunities.
*
* IN NO EVENT SHALL LOCUSWORKS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF LOCUSWORKS HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NO RESPONSIBILITY IS ASSUMED BY
* LOCUSWORKS FOR ITS USE, OR FOR ANY INFRINGEMENTS OF PATENTS OR OTHER RIGHTS OF
* THIRD PARTIES RESULTING FROM ITS USE. LOCUSWORKS SPECIFICALLY DISCLAIMS ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND
* ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
* IS". LOCUSWORKS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*/
package net.locusworks.crypto.tests;
import static org.junit.Assert.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
@ -8,8 +37,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import org.junit.AfterClass;
import org.junit.Test;
import net.locusworks.crypto.configuration.PropertiesManager;
@ -51,7 +78,7 @@ public class PropertiesManagerTest {
}
}
@AfterClass
@AfterAll
public static void removeSavedProps() {
File tmp = new File(TMP_PROPS);
if (tmp.exists()) {

View File

@ -1,4 +1,4 @@
/**
/*
*
* Project: Crypto, File: RandomStringTest.java
*
@ -27,9 +27,8 @@
*/
package net.locusworks.crypto.tests;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import net.locusworks.crypto.utils.RandomString;
@ -41,7 +40,7 @@ public class RandomStringTest {
assertTrue(RandomString.getBytes(length).length == length);
}
}
@Test
public void testStaticString() {
for (Integer length = 3; length < 50; length++) {