diff --git a/.travis.yml b/.travis.yml
index f6f589d..53ca23e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,12 @@ env:
global:
secure: B5ZEHKFRa11V7e9JZwr4vGFSdo1lvnbxijd00mm41qbvwT5YFSMZhEQLRVlDmxhsqcc6guC84Q49LsY3/4rlzspHe8fkByY2sQUM3aXuK13/lJJT8CeDXxYAicWMPBLvybpt3ML1wXcbskQzv5C7oNLgkeMwvpd2zw5pYMV2dHwRhRkfsYgH7hzlVgCOMnPLHfPiDgjuQK6KJUr1qlO4Y9vmFsCiCi94fLHIxu+MsvFy3XRnnlTERTGQCeBD2GGHTH5wjiwTL0GHdKX/ntpODyWZAnbYs8OYsLuCq7QQHJDk4uBVCnMIj1zt6lwxa0iiz+uuvxnL6msSeF/BkIWG/yxRkBjdVtdJL0WBEIDmfzeEugdNFke1I2dsH68Fe+R2syUwIjJ654HSoLZ/xL9Dbnxo8wmix2cO46ictXN3WVNrWwB4KUV5N+aGW/hB0KRqSsO2iUmXqweifJz7qfWm20Y//pgtMtVTnZVTneiSCPucY1QWQmiOgC0jcseV+oIbpFjbYArxGhhPhqJqAWYhJeR/7uX872zMwPqpyHRF3y1XQ+C2xI9IWC2SqjinCsgUnZei1pu7A4Qd34Isd8uCICrLMu8JPe98+Dc+jksGrH/SgOcDI/pffnD2rk/ablNU7JY8yE2t5me9B6SAxOEOyle60i5WiRHcM+pZukBwvwU=
-script: mvn test
+script:
+ # TODO check style
+ - mvn test
notifications:
+ # Email notifications are disabled to not annoy anybody.
+ # See http://about.travis-ci.org/docs/user/build-configuration/ to learn more
+ # about configuring notification recipients and more.
email: false
diff --git a/coniks_common/pom.xml b/coniks_common/pom.xml
index 3ef2488..9838439 100644
--- a/coniks_common/pom.xml
+++ b/coniks_common/pom.xml
@@ -18,13 +18,6 @@
Common message spec and encoding library for CONIKS.
-
- junit
- junit
- 4.12
- test
-
-
com.google.protobuf
protobuf-java
diff --git a/coniks_server/pom.xml b/coniks_server/pom.xml
index 36907f5..0fd7e2d 100644
--- a/coniks_server/pom.xml
+++ b/coniks_server/pom.xml
@@ -19,13 +19,6 @@
-
- junit
- junit
- 4.12
- test
-
-
org.coniks.coniks_common
coniks_common
diff --git a/coniks_server/src/main/java/org/coniks/coniks_server/KeyOps.java b/coniks_server/src/main/java/org/coniks/coniks_server/KeyOps.java
index 446d91a..2427c17 100644
--- a/coniks_server/src/main/java/org/coniks/coniks_server/KeyOps.java
+++ b/coniks_server/src/main/java/org/coniks/coniks_server/KeyOps.java
@@ -1,33 +1,33 @@
/*
Copyright (c) 2015-16, Princeton University.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
+ modification, are permitted provided that the following conditions are
met:
- * Redistributions of source code must retain the above copyright
+ * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following disclaimer
- in the documentation and/or other materials provided with the
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
distribution.
* Neither the name of Princeton University nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
@@ -45,7 +45,7 @@ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
import org.coniks.coniks_common.C2SProtos.DSAPublicKeyProto;
-/** Implements all encryption-key related operations that a
+/** Implements all encryption-key related operations that a
* CONIKS server must perform.
* Current encryption/signing algorithm used: RSA with SHA-256.
*
@@ -70,14 +70,14 @@ public static RSAPrivateKey loadSigningKey(){
// get user password and file input stream
char[] ks_password = ServerConfig.getKeystorePassword().toCharArray();
-
+
FileInputStream fis = null;
-
+
fis = new FileInputStream(ServerConfig.getKeystorePath());
ks.load(fis, ks_password);
if(ks.isKeyEntry(ServerConfig.getName())){
- KeyStore.ProtectionParameter protParam =
+ KeyStore.ProtectionParameter protParam =
new KeyStore.PasswordProtection(ks_password);
KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
@@ -92,13 +92,13 @@ public static RSAPrivateKey loadSigningKey(){
}
catch(IOException e){
TimerLogger.error("KeyOps:loadSigningKey: Problem loading the keystore");
- }
+ }
catch(NoSuchAlgorithmException e){
TimerLogger.error("KeyOps:loadSigningKey: Problem with integrity check algorithm");
}
catch(CertificateException e){
TimerLogger.error("KeyOps:loadSigningKey: Problem with the cert(s) in keystore");
- }
+ }
catch(KeyStoreException e){
TimerLogger.error("KeyOps:loadSigningKey: Problem getting Keystore instance");
}
@@ -111,7 +111,7 @@ public static RSAPrivateKey loadSigningKey(){
/** Load the given server {@code keyOwner}'s public key from the truststore
* indicated in this server's configuration {@code config}.
*
- *@return The {@code keyOwner}'s public RSA key, or {@code null} in
+ *@return The {@code keyOwner}'s public RSA key, or {@code null} in
* the case of an Exception.
*/
public static RSAPublicKey loadPublicKey(String keyOwner){
@@ -123,14 +123,14 @@ public static RSAPublicKey loadPublicKey(String keyOwner){
ks = KeyStore.getInstance(KeyStore.getDefaultType());
char[] ts_password = ServerConfig.getTruststorePassword().toCharArray();
-
+
FileInputStream fis = null;
-
+
fis = new FileInputStream(ServerConfig.getTruststorePath());
ks.load(fis, ts_password);
if(ks.isKeyEntry(keyOwner)){
- KeyStore.ProtectionParameter protParam =
+ KeyStore.ProtectionParameter protParam =
new KeyStore.PasswordProtection(ts_password);
KeyStore.TrustedCertificateEntry pkEntry = (KeyStore.TrustedCertificateEntry)
@@ -145,13 +145,13 @@ public static RSAPublicKey loadPublicKey(String keyOwner){
}
catch(IOException e){
ServerLogger.error("KeyOps:loadPublicKey: Problem loading the keystore");
- }
+ }
catch(NoSuchAlgorithmException e){
ServerLogger.error("KeyOps:loadPublicKey: Problem with integrity check algorithm");
}
catch(CertificateException e){
ServerLogger.error("KeyOps:loadPublicKey: Problem with the cert(s) in keystore");
- }
+ }
catch(KeyStoreException e){
ServerLogger.error("KeyOps:loadPublicKey: Problem getting Keystore instance");
}
diff --git a/coniks_test_client/pom.xml b/coniks_test_client/pom.xml
index fd26f4a..257bc59 100644
--- a/coniks_test_client/pom.xml
+++ b/coniks_test_client/pom.xml
@@ -19,13 +19,6 @@
-
- junit
- junit
- 4.12
- test
-
-
org.coniks.coniks_common
coniks_common
diff --git a/crypto/pom.xml b/crypto/pom.xml
index 4841940..ae287bd 100644
--- a/crypto/pom.xml
+++ b/crypto/pom.xml
@@ -20,28 +20,6 @@
Cryptographic algorithms and operations library for CONIKS.
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.19.1
-
- false
-
-
-
-
-
UTF-8
diff --git a/crypto/src/main/java/org/coniks/crypto/Keys.java b/crypto/src/main/java/org/coniks/crypto/Keys.java
new file mode 100644
index 0000000..0033516
--- /dev/null
+++ b/crypto/src/main/java/org/coniks/crypto/Keys.java
@@ -0,0 +1,134 @@
+/*
+ Copyright (c) 2015-16, Princeton University.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Princeton University nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.coniks.crypto;
+
+import java.security.*;
+import java.security.interfaces.*;
+import java.security.spec.*;
+import java.math.BigInteger;
+
+/** Implements all encryption-key related operations that a
+ * CONIKS server must perform.
+ * Current encryption/signing algorithm used: RSA with SHA-256.
+ *
+ *@author Marcela S. Melara (melara@cs.princeton.edu)
+ *@author Michael Rochlin
+ */
+public class Keys {
+
+ /** Generates a DSA key pair.
+ *
+ *@return the DSA key pair or null in case of an error.
+ */
+ public static KeyPair generateDSAKeyPair()
+ throws NoSuchAlgorithmException {
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");
+ gen.initialize(1024);
+
+ KeyPair pair = gen.generateKeyPair();
+
+ return pair;
+ }
+
+ /** Get the private key from the DSA key pair.
+ *
+ *@param kp The DSA KeyPair.
+ *@return the DSA private key.
+ */
+ public static DSAPrivateKey getDSAPrivate(KeyPair kp) {
+ return (DSAPrivateKey)kp.getPrivate();
+ }
+
+ /** Get the public key from the DSA key pair.
+ *
+ *@param kp The DSA KeyPair.
+ *@return the DSA public key.
+ */
+ public static DSAPublicKey getDSAPublic(KeyPair kp) {
+ return (DSAPublicKey)kp.getPublic();
+ }
+
+ /** Makes a {@link DSAPublicKey} from its {@code p}, {@code q},
+ * {@code g} and {@code y} parameters.
+ *
+ *@return the DSAPublicKey, or {@code null} in case of an error.
+ */
+ public static DSAPublicKey getDSAPublicFromParams(BigInteger p, BigInteger q,
+ BigInteger g, BigInteger y) {
+
+ DSAPublicKey pk = null;
+ try {
+ KeyFactory keyFactory = KeyFactory.getInstance("DSA");
+ KeySpec publicKeySpec = new DSAPublicKeySpec(y, p, q, g);
+ pk = (DSAPublicKey)keyFactory.generatePublic(publicKeySpec);
+ }
+ // let's panic if an exception occurs
+ finally {
+ return pk;
+ }
+ }
+
+ /** Generates an RSA key pair.
+ *
+ *@return the RSA key pair or null in case of an error.
+ */
+ public static KeyPair generateRSAKeyPair()
+ throws NoSuchAlgorithmException {
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
+ gen.initialize(2048);
+
+ KeyPair pair = gen.generateKeyPair();
+
+ return pair;
+ }
+
+ /** Get the private key from the RSA key pair.
+ *
+ *@param kp The RSA KeyPair.
+ *@return the RSA private key.
+ */
+ public static RSAPrivateKey getRSAPrivate(KeyPair kp) {
+ return (RSAPrivateKey)kp.getPrivate();
+ }
+
+ /** Get the public key from the RSA key pair.
+ *
+ *@param kp The RSA KeyPair.
+ *@return the RSA public key.
+ */
+ public static RSAPublicKey getRSAPublic(KeyPair kp) {
+ return (RSAPublicKey)kp.getPublic();
+ }
+
+}
diff --git a/crypto/src/main/java/org/coniks/crypto/Signing.java b/crypto/src/main/java/org/coniks/crypto/Signing.java
index c5d44af..44f1f59 100644
--- a/crypto/src/main/java/org/coniks/crypto/Signing.java
+++ b/crypto/src/main/java/org/coniks/crypto/Signing.java
@@ -1,41 +1,47 @@
/*
Copyright (c) 2015-16, Princeton University.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
+ modification, are permitted provided that the following conditions are
met:
- * Redistributions of source code must retain the above copyright
+ * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following disclaimer
- in the documentation and/or other materials provided with the
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
distribution.
* Neither the name of Princeton University nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.coniks.crypto;
-import java.security.*;
-import java.security.spec.*;
-import java.security.interfaces.*;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.Signature;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
/** Implements all digital signature operations for CONIKS.
* Current supported algorithms: RSA with SHA-256 and DSA.
@@ -47,25 +53,28 @@ public class Signing {
/** Generate the RSA digital signature of {@code msg} using {@code key}.
*
+ *@param msg The message to be signed.
+ *@param key The {@link java.security.interfaces.RSAPrivateKey} to use
+ * for signing.
*@return The {@code byte[]} containing the digital signature
* of the {@code msg}, or null in case of an error.
- *@throws {@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
+ *@throws java.security.NoSuchAlgorithmException
*/
- public static byte[] rsaSign(RSAPrivateKey key, byte[] msg)
+ public static byte[] rsaSign(RSAPrivateKey key, byte[] msg)
throws NoSuchAlgorithmException {
-
+
byte[] sig = null;
- try{
- Signature signer = Signature.getInstance("SHA256withRSA");
- signer.initSign(key, new SecureRandom());
+ try {
+ Signature signer = Signature.getInstance("SHA256withRSA");
+ signer.initSign(key, new SecureRandom());
signer.update(msg);
-
- sig = signer.sign();
- }
+
+ sig = signer.sign();
+ }
// let's panic if an exception occurs
finally {
return sig;
- }
+ }
}
/** Verify the RSA signature {@code sig} of {@code msg} using {@code pk}.
@@ -74,18 +83,17 @@ public static byte[] rsaSign(RSAPrivateKey key, byte[] msg)
* otherwise.
*@throws {@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
*/
- public static boolean rsaVerify(RSAPublicKey pk, byte[] msg, byte[] sig)
+ public static boolean rsaVerify(RSAPublicKey pk, byte[] msg, byte[] sig)
throws NoSuchAlgorithmException {
boolean res = false;
- try{
-
- Signature verifier = Signature.getInstance("SHA256withRSA");
- verifier.initVerify(pk);
- verifier.update(msg);
-
- res = verifier.verify(sig);
- }
+ try {
+ Signature verifier = Signature.getInstance("SHA256withRSA");
+ verifier.initVerify(pk);
+ verifier.update(msg);
+
+ res = verifier.verify(sig);
+ }
// let's panic if an exception occurs
finally {
return res;
@@ -94,13 +102,17 @@ public static boolean rsaVerify(RSAPublicKey pk, byte[] msg, byte[] sig)
/** Generate the DSA digital signature of {@code msg} using {@code key}.
*
+ *@param msg The message to be signed.
+ *@param key The {@link java.security.interfaces.DSAPrivateKey} to use
+ * for signing.
*@return The {@code byte[]} containing the digital signature
* of the {@code msg}, or null in case of an error.
- *@throws {@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
+ *@throws
+ *{@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
*/
- public static byte[] dsaSign(DSAPrivateKey key, byte[] msg)
+ public static byte[] dsaSign(DSAPrivateKey key, byte[] msg)
throws NoSuchAlgorithmException {
-
+
byte[] sig = null;
try {
Signature sigProcess = Signature.getInstance("DSA");
@@ -116,11 +128,13 @@ public static byte[] dsaSign(DSAPrivateKey key, byte[] msg)
/** Verify the DSA signature {@code sig} of {@code msg} using {@code pk}.
*
- *@return {@code true} if the signature on the message is valid, {@code false}
+ *@return {@code true} if the signature on the message is valid,
+ * {@code false}
* otherwise.
- *@throws {@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
+ *@throws
+ *{@link java.security.NoSuchAlgorithmException NoSuchAlgorithmException}
*/
- public static boolean dsaVerify(DSAPublicKey pk, byte[] msg, byte[] sig)
+ public static boolean dsaVerify(DSAPublicKey pk, byte[] msg, byte[] sig)
throws NoSuchAlgorithmException {
boolean res = false;
diff --git a/crypto/src/test/java/org/coniks/crypto/SigningTest.java b/crypto/src/test/java/org/coniks/crypto/SigningTest.java
index b7455a2..0c0758f 100644
--- a/crypto/src/test/java/org/coniks/crypto/SigningTest.java
+++ b/crypto/src/test/java/org/coniks/crypto/SigningTest.java
@@ -6,7 +6,10 @@
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.interfaces.*;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
/**
* Unit tests for Signing.
@@ -15,32 +18,30 @@ public class SigningTest
{
@Test
- public void testRsaSignVerify()
+ public void testRsaSignVerify()
throws NoSuchAlgorithmException {
- KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
- gen.initialize(2048);
- KeyPair pair = gen.generateKeyPair();
+ KeyPair pair = Keys.generateRSAKeyPair();
byte[] msg = "message".getBytes();
- byte[] sig = Signing.rsaSign((RSAPrivateKey)pair.getPrivate(), msg);
+ byte[] sig = Signing.rsaSign(Keys.getRSAPrivate(pair), msg);
- assertTrue("RSA signature of message using same key pair can be verified", Signing.rsaVerify((RSAPublicKey)pair.getPublic(), msg, sig));
+ assertTrue("RSA signature of message using same key pair can be verified",
+ Signing.rsaVerify(Keys.getRSAPublic(pair), msg, sig));
}
@Test
- public void testDsaSignVerify()
+ public void testDsaSignVerify()
throws NoSuchAlgorithmException {
- KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");
- gen.initialize(1024);
- KeyPair pair = gen.generateKeyPair();
+ KeyPair pair = Keys.generateDSAKeyPair();
byte[] msg = "message".getBytes();
- byte[] sig = Signing.dsaSign((DSAPrivateKey)pair.getPrivate(), msg);
+ byte[] sig = Signing.dsaSign(Keys.getDSAPrivate(pair), msg);
- assertTrue("DSA signature of message using same key pair can be verified", Signing.dsaVerify((DSAPublicKey)pair.getPublic(), msg, sig));
+ assertTrue("DSA signature of message using same key pair can be verified",
+ Signing.dsaVerify(Keys.getDSAPublic(pair), msg, sig));
}
}
diff --git a/pom.xml b/pom.xml
index a9bf345..bff89ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,6 +12,15 @@
CONIKS is a key management system that provides transparency for end-user public keys.
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
@@ -22,6 +31,32 @@
$COVERALLS_TOKEN
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.19.1
+
+
+
+ unit-tests
+
+ report
+
+
+
+
+
+ unit-tests-aggregate
+ false
+
+ report
+
+
+ true
+
+
+
+