diff --git a/cert/src/main/java/org/openjax/security/cert/X509Certificates.java b/cert/src/main/java/org/openjax/security/cert/X509Certificates.java index fa987b1..4897c6c 100644 --- a/cert/src/main/java/org/openjax/security/cert/X509Certificates.java +++ b/cert/src/main/java/org/openjax/security/cert/X509Certificates.java @@ -287,12 +287,12 @@ public static X509Certificate decodeCertificate(final InputStream in) throws Cer } /** - * Returns a collection of {@link X509Certificate}s from the specified {@link InputStream} that provides a DER-formatted - * certificate chain. + * Returns a collection of {@link X509Certificate}s from the specified {@link InputStream} that provides a DER-formatted certificate + * chain. * * @param in An {@link InputStream} providing a DER-formatted certificate. - * @return A collection of {@link X509Certificate}s from the specified {@link InputStream} that provides a DER-formatted - * certificate chain. + * @return A collection of {@link X509Certificate}s from the specified {@link InputStream} that provides a DER-formatted certificate + * chain. * @throws CertificateException If an exception occurs parsing the DER-formatted certificate chain from the provided * {@link InputStream}. * @throws NullPointerException If {@code in} is null. @@ -316,8 +316,7 @@ public static Collection decodeCertificateChain(final InputStre * * @param der A {@code byte[]} DER-formatted certificate. * @return A {@link X509Certificate} from the specified {@code byte[]} DER-formatted certificate. - * @throws CertificateException If an exception occurs parsing the DER-formatted certificate from the provided - * {@link InputStream}. + * @throws CertificateException If an exception occurs parsing the DER-formatted certificate from the provided {@link InputStream}. * @throws NullPointerException If {@code der} is null. */ public static X509Certificate decodeCertificate(final byte[] der) throws CertificateException { @@ -329,8 +328,7 @@ public static X509Certificate decodeCertificate(final byte[] der) throws Certifi * * @param der A {@code byte[]} DER-formatted certificate. * @return A collection of {@link X509Certificate}s from the specified {@code byte[]} DER-formatted certificate chain. - * @throws CertificateException If an exception occurs parsing the DER-formatted certificate from the provided - * {@link InputStream}. + * @throws CertificateException If an exception occurs parsing the DER-formatted certificate from the provided {@link InputStream}. * @throws NullPointerException If {@code der} is null. */ public static Collection decodeCertificateChain(final byte[] der) throws CertificateException { @@ -338,15 +336,15 @@ public static Collection decodeCertificateChain(final byte[] de } /** - * Returns a new {@link KeyStore} instance that is loaded and initialized from the provided {@link InputStream}, and unlocked if - * the provided {@code storePassword} is not null. The type of the new {@link KeyStore} is the default keystore type as specified - * by the {@code keystore.type} {@linkplain java.security.Security#getProperty security property}, or the string "jks" (acronym - * for "Java keystore") if no such property exists. + * Returns a new {@link KeyStore} instance that is loaded and initialized from the provided {@link InputStream}, and unlocked if the + * provided {@code storePassword} is not null. The type of the new {@link KeyStore} is the default keystore type as specified by the + * {@code keystore.type} {@linkplain java.security.Security#getProperty security property}, or the string "jks" (acronym for "Java + * keystore") if no such property exists. * * @param url * @param storePassword - * @return A new {@link KeyStore} instance that is loaded and initialized from the provided {@link InputStream}, and unlocked if - * the provided {@code storePassword} is not null. + * @return A new {@link KeyStore} instance that is loaded and initialized from the provided {@link InputStream}, and unlocked if the + * provided {@code storePassword} is not null. * @throws CertificateException If any of the certificates in the keystore could not be loaded. * @throws IOException If an I/O error has occurred. * @throws KeyStoreException If no {@link java.security.Provider} supports a {@link java.security.KeyStoreSpi} implementation for @@ -395,8 +393,8 @@ private static X509Certificate[] convertCertPathToX509CertArray(final Listvalid certificate path rebuilt from the provided {@code clientCert} and the given {@code trustedRootCerts}, or * {@code null} if no valid path exists. - * @throws NullPointerException If {@code clientCert}, or {@code trustedRootCerts} or any member of {@code trustedRootCerts} - * is null. + * @throws NullPointerException If {@code clientCert}, or {@code trustedRootCerts} or any member of {@code trustedRootCerts} is + * null. */ public static X509Certificate[] getCertificatePath(final X509Certificate clientCert, final Set trustedRootCerts) { return getCertificatePath(clientCert, trustedRootCerts, null); @@ -408,12 +406,11 @@ public static X509Certificate[] getCertificatePath(final X509Certificate clientC * * @param clientCert The client {@link X509Certificate}. * @param trustedRootCerts The root certificates of the {@linkplain KeyStore Trust Store} specifying the certificate chain. - * @param intermediateCerts The intermediate certificates of the {@linkplain KeyStore Trust Store} specifying the certificate - * chain. + * @param intermediateCerts The intermediate certificates of the {@linkplain KeyStore Trust Store} specifying the certificate chain. * @return A valid certificate path from the provided {@code clientCert} and the given {@code trustedRootCerts} and * {@code intermediateCerts}, or {@code null} if no valid path exists. - * @throws NullPointerException If {@code clientCert}, or {@code trustedRootCerts} or any member of {@code trustedRootCerts} - * is null. + * @throws NullPointerException If {@code clientCert}, or {@code trustedRootCerts} or any member of {@code trustedRootCerts} is + * null. */ public static X509Certificate[] getCertificatePath(final X509Certificate clientCert, final Set trustedRootCerts, Set intermediateCerts) { intermediateCerts = intermediateCerts != null ? new HashSet<>(intermediateCerts) : new HashSet<>(); @@ -453,15 +450,18 @@ public static X509Certificate[] getCertificatePath(final X509Certificate clientC final List certificates = certPath.getCertificates(); final int noCertificates = certificates.size(); - if (logger.isDebugEnabled()) logger.debug("Certification path built with " + noCertificates + " X.509 Certificates"); + if (logger.isDebugEnabled()) + logger.debug("Certification path built with " + noCertificates + " X.509 Certificates"); final X509Certificate[] certificateChain = convertCertPathToX509CertArray(certificates, noCertificates, 0, 0); - if (logger.isDebugEnabled()) logger.debug("Client certificate (valid): SubjectDN=[" + clientCert.getSubjectDN() + "] SerialNumber=[" + clientCert.getSerialNumber() + "]"); + if (logger.isDebugEnabled()) + logger.debug("Client certificate (valid): SubjectDN=[" + clientCert.getSubjectDN() + "] SerialNumber=[" + clientCert.getSerialNumber() + "]"); return certificateChain; } catch (final CertPathBuilderException e) { if ("unable to find valid certification path to requested target".equals(e.getMessage())) { - if (logger.isDebugEnabled()) logger.debug("Client certificate (invalid): SubjectDN=[" + clientCert.getSubjectDN() + "] SerialNumber=[" + clientCert.getSerialNumber() + "]"); + if (logger.isDebugEnabled()) + logger.debug("Client certificate (invalid): SubjectDN=[" + clientCert.getSubjectDN() + "] SerialNumber=[" + clientCert.getSerialNumber() + "]"); return null; } diff --git a/nacl/src/main/java/org/openjax/security/nacl/Nacl.java b/nacl/src/main/java/org/openjax/security/nacl/Nacl.java index fa7aee5..924705d 100644 --- a/nacl/src/main/java/org/openjax/security/nacl/Nacl.java +++ b/nacl/src/main/java/org/openjax/security/nacl/Nacl.java @@ -65,8 +65,7 @@ public abstract class Nacl { public static final Nacl TweetFast = new NaclTweetFast(); /* - * Port of Andrew Moon's Poly1305-donna-16. Public domain. - * https://github.com/floodyberry/poly1305-donna + * Port of Andrew Moon's Poly1305-donna-16. Public domain. https://github.com/floodyberry/poly1305-donna */ static void cryptoOneTimeAuth(final byte[] out, final int outpos, final byte[] m, final int mpos, final int n, final byte[] k) { final Poly1305 s = new Poly1305(k); @@ -162,13 +161,11 @@ static void cswap(final long[][] p, final long[][] q, final byte b) { } /* - * public static byte[] randombytes(byte [] x, int len) { int ret = len % 8; - * long rnd; for (int i = 0; i < len-ret; i += 8) { rnd = jrandom.nextLong(); // [A] - * x[i+0] = (byte) (rnd >>> 0); x[i+1] = (byte) (rnd >>> 8); x[i+2] = (byte) - * (rnd >>> 16); x[i+3] = (byte) (rnd >>> 24); x[i+4] = (byte) (rnd >>> 32); - * x[i+5] = (byte) (rnd >>> 40); x[i+6] = (byte) (rnd >>> 48); x[i+7] = (byte) - * (rnd >>> 56); } if (ret > 0) { rnd = jrandom.nextLong(); for (int i = // [A] - * len-ret; i < len; i ++) x[i] = (byte) (rnd >>> 8*i); } return x; } + * public static byte[] randombytes(byte [] x, int len) { int ret = len % 8; long rnd; for (int i = 0; i < len-ret; i += 8) { rnd = + * jrandom.nextLong(); // [A] x[i+0] = (byte) (rnd >>> 0); x[i+1] = (byte) (rnd >>> 8); x[i+2] = (byte) (rnd >>> 16); x[i+3] = + * (byte) (rnd >>> 24); x[i+4] = (byte) (rnd >>> 32); x[i+5] = (byte) (rnd >>> 40); x[i+6] = (byte) (rnd >>> 48); x[i+7] = (byte) + * (rnd >>> 56); } if (ret > 0) { rnd = jrandom.nextLong(); for (int i = // [A] len-ret; i < len; i ++) x[i] = (byte) (rnd >>> 8*i); + * } return x; } */ private static byte[] randombytes(final byte[] x) { @@ -235,11 +232,11 @@ public final void setNonce(final long nonce) { } public final long getNonce() { - return this.nonce.get(); + return nonce.get(); } public final long incrNonce() { - return this.nonce.incrementAndGet(); + return nonce.incrementAndGet(); } final byte[] generateNonce() { @@ -302,12 +299,12 @@ final byte[] generateNonce() { * @return A precomputed shared key which can be used in nacl.box.after and nacl.box.open.after. */ public final byte[] before() { - if (this.sharedKey == null) { - this.sharedKey = new byte[sharedKeyLength]; - nacl.cryptoBoxBeforeNm(this.sharedKey, this.theirPublicKey, this.mySecretKey); + if (sharedKey == null) { + sharedKey = new byte[sharedKeyLength]; + nacl.cryptoBoxBeforeNm(sharedKey, theirPublicKey, mySecretKey); } - return this.sharedKey; + return sharedKey; } } @@ -324,7 +321,6 @@ public abstract class SecretBox { SecretBox(final byte[] key, final long nonce) { this.key = key; - this.nonce = new AtomicLong(nonce); } @@ -333,11 +329,11 @@ public final void setNonce(final long nonce) { } public final long getNonce() { - return this.nonce.get(); + return nonce.get(); } public final long incNonce() { - return this.nonce.incrementAndGet(); + return nonce.incrementAndGet(); } final byte[] generateNonce() { @@ -359,8 +355,8 @@ final byte[] generateNonce() { } /** - * Encrypt and authenticates message using the key and the nonce. The nonce must be unique for each distinct message for this - * key. // [A] + * Encrypt and authenticates message using the key and the nonce. The nonce must be unique for each distinct message for this key. + * // [A] * * @param message The message. * @return An encrypted and authenticated message, which is nacl.secretbox.overheadLength longer than the original message. @@ -431,7 +427,7 @@ public abstract class Signature { * @return The signature. */ public final byte[] detached(final byte[] message) { - final byte[] signedMsg = this.sign(message); + final byte[] signedMsg = sign(message); final byte[] sig = new byte[signatureLength]; System.arraycopy(signedMsg, 0, sig, 0, sig.length); @@ -588,12 +584,9 @@ public final void cryptoBoxBeforeNm(final byte[] k, final byte[] y, final byte[] cryptoScalarMult(s, x, y); /* - * String dbgt = ""; for (int dbg = 0; dbg < s.length; dbg ++) dbgt += - * " "+s[dbg]; Log.d(TAG, "crypto_box_beforenm -> "+dbgt); dbgt = ""; for - * (int dbg = 0; dbg < x.length; dbg ++) dbgt += " "+x[dbg]; Log.d(TAG, - * "crypto_box_beforenm, x -> "+dbgt); dbgt = ""; for (int dbg = 0; dbg < - * y.length; dbg ++) dbgt += " "+y[dbg]; Log.d(TAG, - * "crypto_box_beforenm, y -> "+dbgt); + * String dbgt = ""; for (int dbg = 0; dbg < s.length; dbg ++) dbgt += " "+s[dbg]; Log.d(TAG, "crypto_box_beforenm -> "+dbgt); dbgt + * = ""; for (int dbg = 0; dbg < x.length; dbg ++) dbgt += " "+x[dbg]; Log.d(TAG, "crypto_box_beforenm, x -> "+dbgt); dbgt = ""; for + * (int dbg = 0; dbg < y.length; dbg ++) dbgt += " "+y[dbg]; Log.d(TAG, "crypto_box_beforenm, y -> "+dbgt); */ cryptoCoreHsalsa20(k, _0, s, sigma); diff --git a/nacl/src/main/java/org/openjax/security/nacl/NaclTweet.java b/nacl/src/main/java/org/openjax/security/nacl/NaclTweet.java index ee66f3c..dc2ee9b 100644 --- a/nacl/src/main/java/org/openjax/security/nacl/NaclTweet.java +++ b/nacl/src/main/java/org/openjax/security/nacl/NaclTweet.java @@ -458,30 +458,20 @@ private void cryptoStreamXor(final byte[] c, final byte[] m, final long d, final } /* - * !!! Use TweetNaclFast.java onetimeauth function private static void - * add1305(int [] h,int [] c) { int j; int u = 0; for (j = 0; j < 17; j ++) { - * u = (u + ((h[j] + c[j]) | 0)) | 0; h[j] = u & 255; u >>>= 8; } } private - * static final int minusp[] = { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - * 0, 252 }; private static int crypto_onetimeauth( byte[] out,final int - * outoff,final int outlen, byte[] m,final int moff,final int mlen, long n, - * byte [] k) { int i,j; int s,u; int [] x = new int[17], r = new int [17], h - * = new int[17], c = new int [17], g = new int[17]; for (j = 0; j < 17; j ++) - * r[j] = h[j] = 0; for (j = 0; j < 16; j ++) r[j] = k[j] & 0xff; r[3]&=15; - * r[4]&=252; r[7]&=15; r[8]&=252; r[11]&=15; r[12]&=252; r[15]&=15; int - * moffset = moff; while (n > 0) { for (j = 0; j < 17; j ++) c[j] = 0; for (j - * = 0;(j < 16) && (j < n);++j) c[j] = m[j+moffset] & 0xff; c[j] = 1; moffset - * += j; n -= j; add1305(h,c); for (i = 0; i < 17; i ++) { x[i] = 0; for (j = - * 0; j < 17; j ++) x[i] += h[j] * ((j <= i) ? r[i - j] : 320 * r[i + 17 - - * j]); for (j = 0; j < 17; j++) x[i] = (x[i] + (h[j] * ((j <= i) ? r[i - j] : - * ((320 * r[i + 17 - j])|0))) | 0) | 0; } for (i = 0; i < 17; i ++) h[i] = - * x[i]; u = 0; for (j = 0; j < 16; j ++) { u = (u + h[j]) | 0; h[j] = u & - * 255; u >>>= 8; } u = (u + h[16]) | 0; h[16] = u & 3; u = (5 * (u >>> 2)) | - * 0; for (j = 0; j < 16; j ++) { u = (u + h[j]) | 0; h[j] = u & 255; u >>>= - * 8; } u = (u + h[16]) | 0; h[16] = u; } for (j = 0; j < 17; j ++) g[j] = - * h[j]; add1305(h,minusp); s = (-(h[16] >>> 7) | 0); for (j = 0; j < 17; j - * ++) h[j] ^= s & (g[j] ^ h[j]); for (j = 0; j < 16; j ++) c[j] = k[j + 16] & - * 0xff; c[16] = 0; add1305(h,c); for (j = 0; j < 16; j ++) out[j+outoff] = - * (byte) (h[j]&0xff); return 0; } + * !!! Use TweetNaclFast.java onetimeauth function private static void add1305(int [] h,int [] c) { int j; int u = 0; for (j = 0; j + * < 17; j ++) { u = (u + ((h[j] + c[j]) | 0)) | 0; h[j] = u & 255; u >>>= 8; } } private static final int minusp[] = { 5, 0, 0, 0, + * 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 }; private static int crypto_onetimeauth( byte[] out,final int outoff,final int outlen, + * byte[] m,final int moff,final int mlen, long n, byte [] k) { int i,j; int s,u; int [] x = new int[17], r = new int [17], h = new + * int[17], c = new int [17], g = new int[17]; for (j = 0; j < 17; j ++) r[j] = h[j] = 0; for (j = 0; j < 16; j ++) r[j] = k[j] & + * 0xff; r[3]&=15; r[4]&=252; r[7]&=15; r[8]&=252; r[11]&=15; r[12]&=252; r[15]&=15; int moffset = moff; while (n > 0) { for (j = 0; + * j < 17; j ++) c[j] = 0; for (j = 0;(j < 16) && (j < n);++j) c[j] = m[j+moffset] & 0xff; c[j] = 1; moffset += j; n -= j; + * add1305(h,c); for (i = 0; i < 17; i ++) { x[i] = 0; for (j = 0; j < 17; j ++) x[i] += h[j] * ((j <= i) ? r[i - j] : 320 * r[i + + * 17 - j]); for (j = 0; j < 17; j++) x[i] = (x[i] + (h[j] * ((j <= i) ? r[i - j] : ((320 * r[i + 17 - j])|0))) | 0) | 0; } for (i = + * 0; i < 17; i ++) h[i] = x[i]; u = 0; for (j = 0; j < 16; j ++) { u = (u + h[j]) | 0; h[j] = u & 255; u >>>= 8; } u = (u + h[16]) + * | 0; h[16] = u & 3; u = (5 * (u >>> 2)) | 0; for (j = 0; j < 16; j ++) { u = (u + h[j]) | 0; h[j] = u & 255; u >>>= 8; } u = (u + + * h[16]) | 0; h[16] = u; } for (j = 0; j < 17; j ++) g[j] = h[j]; add1305(h,minusp); s = (-(h[16] >>> 7) | 0); for (j = 0; j < 17; + * j ++) h[j] ^= s & (g[j] ^ h[j]); for (j = 0; j < 16; j ++) c[j] = k[j + 16] & 0xff; c[16] = 0; add1305(h,c); for (j = 0; j < 16; + * j ++) out[j+outoff] = (byte) (h[j]&0xff); return 0; } */ private static int cryptoOneTimeAuthVerify(final byte[] h, final int hoff, final int hlen, final byte[] m, final int moff, final int mlen, final int n, final byte[] k) { @@ -813,7 +803,7 @@ public void cryptoSignKeyPair(final byte[] pk, final byte[] sk, final boolean se } // TBD... 64bits of n - private void cryptoSign(final byte[] sm, final long dummy /*smlen not used*/, final byte[] m, final int/* long*/ n, final byte[] sk) { + private void cryptoSign(final byte[] sm, final long dummy /* smlen not used */, final byte[] m, final int/* long */ n, final byte[] sk) { final byte[] d = new byte[64]; final byte[] h = new byte[64]; final byte[] r = new byte[64]; @@ -910,7 +900,7 @@ int unpackneg(final long[][] r, final byte[] p) { // TBD 64bits of mlen @Override - int cryptoSignOpen(final byte[] m, final long dummy /*mlen not used*/, final byte[] sm, final int smoff, int/*long*/ n, final byte[] pk) { + int cryptoSignOpen(final byte[] m, final long dummy /* mlen not used */, final byte[] sm, final int smoff, int/* long */ n, final byte[] pk) { final byte[] t = new byte[32]; final byte[] h = new byte[64]; diff --git a/nacl/src/main/java/org/openjax/security/nacl/NaclTweetFast.java b/nacl/src/main/java/org/openjax/security/nacl/NaclTweetFast.java index eac6dfb..bbe34c7 100644 --- a/nacl/src/main/java/org/openjax/security/nacl/NaclTweetFast.java +++ b/nacl/src/main/java/org/openjax/security/nacl/NaclTweetFast.java @@ -666,8 +666,7 @@ private static void coreSalsa20(final byte[] o, final byte[] p, final byte[] k, o[63] = (byte)(x15 >>> 24 & 0xff); /* - * String dbgt = ""; for (int dbg = 0; dbg < o.length; dbg ++) dbgt += - * " "+o[dbg]; Log.d(TAG, "core_salsa20 -> "+dbgt); + * String dbgt = ""; for (int dbg = 0; dbg < o.length; dbg ++) dbgt += " "+o[dbg]; Log.d(TAG, "core_salsa20 -> "+dbgt); */ } @@ -806,8 +805,7 @@ private static void coreHsalsa20(final byte[] o, final byte[] p, final byte[] k, o[31] = (byte)(x9 >>> 24 & 0xff); /* - * String dbgt = ""; for (int dbg = 0; dbg < o.length; dbg ++) dbgt += - * " "+o[dbg]; Log.d(TAG, "core_hsalsa20 -> "+dbgt); + * String dbgt = ""; for (int dbg = 0; dbg < o.length; dbg ++) dbgt += " "+o[dbg]; Log.d(TAG, "core_hsalsa20 -> "+dbgt); */ } @@ -906,7 +904,7 @@ private void cryptoStreamXor(final byte[] c, final int cpos, final byte[] m, fin cryptoStreamSalsa20Xor(c, cpos, m, mpos, d, sn, s); } - private static int cryptoOneTimeAuthVerify(final byte[] h, final int hoff, final byte[] m, final int moff, final int /*long*/ n, final byte[] k) { + private static int cryptoOneTimeAuthVerify(final byte[] h, final int hoff, final byte[] m, final int moff, final int /* long */ n, final byte[] k) { final byte[] x = new byte[16]; cryptoOneTimeAuth(x, 0, m, moff, n, k); return cryptoVerify16(h, hoff, x, 0); @@ -1706,7 +1704,7 @@ public void cryptoSignKeyPair(final byte[] pk, final byte[] sk, final boolean se } // TBD... 64bits of n - private void cryptoSign(final byte[] sm, final long dummy /*smlen not used*/, final byte[] m, final int moff, final int/*long*/ n, final byte[] sk) { + private void cryptoSign(final byte[] sm, final long dummy /* smlen not used */, final byte[] m, final int moff, final int/* long */ n, final byte[] sk) { final byte[] d = new byte[64]; final byte[] h = new byte[64]; final byte[] r = new byte[64]; @@ -1802,7 +1800,7 @@ int unpackneg(final long[][] r, final byte[] p) { // TBD 64bits of mlen @Override - int cryptoSignOpen(final byte[] m, final long dummy /*mlen not used*/, final byte[] sm, final int smoff, int/*long*/ n, final byte[] pk) { + int cryptoSignOpen(final byte[] m, final long dummy /* mlen not used */, final byte[] sm, final int smoff, int/* long */ n, final byte[] pk) { final byte[] t = new byte[32]; final byte[] h = new byte[64]; diff --git a/nacl/src/main/java/org/openjax/security/nacl/Poly1305.java b/nacl/src/main/java/org/openjax/security/nacl/Poly1305.java index 6526970..b05e98f 100644 --- a/nacl/src/main/java/org/openjax/security/nacl/Poly1305.java +++ b/nacl/src/main/java/org/openjax/security/nacl/Poly1305.java @@ -347,12 +347,9 @@ Poly1305 finish(final byte[] mac, final int macpos) { g[9] &= 0xffff; /* - * backport from tweetnacl-fast.js - * https://github.com/dchest/tweetnacl-js/releases/tag/v0.14.3 <<< "The - * issue was not properly detecting if st->h was >= 2^130 - 5, coupled - * with [testing mistake] not catching the failure. The chance of the bug - * affecting anything in the real world is essentially zero luckily, but - * it's good to have it fixed." >>> + * backport from tweetnacl-fast.js https://github.com/dchest/tweetnacl-js/releases/tag/v0.14.3 <<< "The issue was not properly + * detecting if st->h was >= 2^130 - 5, coupled with [testing mistake] not catching the failure. The chance of the bug affecting + * anything in the real world is essentially zero luckily, but it's good to have it fixed." >>> */ // change mask = (g[9] >>> ((2 * 8) - 1)) - 1; to as mask = (c ^ 1) - 1; diff --git a/nacl/src/test/java/org/openjax/security/nacl/NaclTweetFastTest.java b/nacl/src/test/java/org/openjax/security/nacl/NaclTweetFastTest.java index 0b27f75..2c4e171 100644 --- a/nacl/src/test/java/org/openjax/security/nacl/NaclTweetFastTest.java +++ b/nacl/src/test/java/org/openjax/security/nacl/NaclTweetFastTest.java @@ -299,24 +299,24 @@ public void testSecretBox() { logger.debug(TAG, "\n\n\tstreess/" + (mb0.length / 1000.0) + "kB: " + t + " times"); /* - * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; - * i ++) mb0t += " "+mb0[i]; logger.debug(TAG, mb0t); + * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; i ++) mb0t += " "+mb0[i]; logger.debug(TAG, + * mb0t); */ logger.debug(TAG, "secret box ...@" + System.currentTimeMillis()); final byte[] cab = pab.box(mb0); logger.debug(TAG, "... secret box@" + System.currentTimeMillis()); /* - * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; - * i ++) cabt += " "+cab[i]; logger.debug(TAG, cabt); + * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; i ++) cabt += " "+cab[i]; logger.debug(TAG, + * cabt); */ logger.debug(TAG, "\nsecret box open ...@" + System.currentTimeMillis()); final byte[] mba = pba.open(cab); logger.debug(TAG, "... secret box open@" + System.currentTimeMillis()); /* - * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; - * i ++) mbat += " "+mba[i]; logger.debug(TAG, mbat); + * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; i ++) mbat += " "+mba[i]; logger.debug(TAG, + * mbat); */ final String nm0 = new String(mba, StandardCharsets.UTF_8); @@ -357,24 +357,24 @@ public void testSecretBoxNonce() { logger.debug(TAG, "\n\n\tstress/" + (mb0.length / 1000.0) + "kB: " + t + " times"); /* - * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; - * i ++) mb0t += " "+mb0[i]; logger.debug(TAG, mb0t); + * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; i ++) mb0t += " "+mb0[i]; logger.debug(TAG, + * mb0t); */ logger.debug(TAG, "secret box ...@" + System.currentTimeMillis()); final byte[] cab = pab.box(mb0, theNonce); logger.debug(TAG, "... secret box@" + System.currentTimeMillis()); /* - * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; - * i ++) cabt += " "+cab[i]; logger.debug(TAG, cabt); + * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; i ++) cabt += " "+cab[i]; logger.debug(TAG, + * cabt); */ logger.debug(TAG, "\nsecret box open ...@" + System.currentTimeMillis()); final byte[] mba = pba.open(cab, theNonce); logger.debug(TAG, "... secret box open@" + System.currentTimeMillis()); /* - * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; - * i ++) mbat += " "+mba[i]; logger.debug(TAG, mbat); + * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; i ++) mbat += " "+mba[i]; logger.debug(TAG, + * mbat); */ final String nm0 = new String(mba, StandardCharsets.UTF_8); diff --git a/nacl/src/test/java/org/openjax/security/nacl/NaclTweetTest.java b/nacl/src/test/java/org/openjax/security/nacl/NaclTweetTest.java index 1587e1e..910d9a9 100644 --- a/nacl/src/test/java/org/openjax/security/nacl/NaclTweetTest.java +++ b/nacl/src/test/java/org/openjax/security/nacl/NaclTweetTest.java @@ -216,24 +216,24 @@ public void testSecretBox() { logger.debug(TAG, "\n\n\tstress/" + (mb0.length / 1000.0) + "kB: " + t + " times"); /* - * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; - * i ++) mb0t += " "+mb0[i]; logger.debug(TAG, mb0t); + * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; i ++) mb0t += " "+mb0[i]; logger.debug(TAG, + * mb0t); */ logger.debug(TAG, "secret box ...@" + System.currentTimeMillis()); final byte[] cab = pab.box(mb0); logger.debug(TAG, "... secret box@" + System.currentTimeMillis()); /* - * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; - * i ++) cabt += " "+cab[i]; logger.debug(TAG, cabt); + * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; i ++) cabt += " "+cab[i]; logger.debug(TAG, + * cabt); */ logger.debug(TAG, "\nsecret box open ...@" + System.currentTimeMillis()); final byte[] mba = pba.open(cab); logger.debug(TAG, "... secret box open@" + System.currentTimeMillis()); /* - * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; - * i ++) mbat += " "+mba[i]; logger.debug(TAG, mbat); + * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; i ++) mbat += " "+mba[i]; logger.debug(TAG, + * mbat); */ final String nm0 = new String(mba, StandardCharsets.UTF_8); @@ -275,24 +275,24 @@ public void testSecretBoxNonce() { logger.debug(TAG, "\n\n\tstress/" + (mb0.length / 1000.0) + "kB: " + t + " times"); /* - * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; - * i ++) mb0t += " "+mb0[i]; logger.debug(TAG, mb0t); + * String mb0t = "mb0/"+mb0.length + ": "; for (int i = 0, i$ = mb0.length; i < i$; i ++) mb0t += " "+mb0[i]; logger.debug(TAG, + * mb0t); */ logger.debug(TAG, "secret box ...@" + System.currentTimeMillis()); final byte[] cab = pab.box(mb0, theNonce); logger.debug(TAG, "... secret box@" + System.currentTimeMillis()); /* - * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; - * i ++) cabt += " "+cab[i]; logger.debug(TAG, cabt); + * String cabt = "cab/"+cab.length + ": "; for (int i = 0, i$ = cab.length; i < i$; i ++) cabt += " "+cab[i]; logger.debug(TAG, + * cabt); */ logger.debug(TAG, "\nsecret box open ...@" + System.currentTimeMillis()); final byte[] mba = pba.open(cab, theNonce); logger.debug(TAG, "... secret box open@" + System.currentTimeMillis()); /* - * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; - * i ++) mbat += " "+mba[i]; logger.debug(TAG, mbat); + * String mbat = "mba/"+mba.length + ": "; for (int i = 0, i$ = mba.length; i < i$; i ++) mbat += " "+mba[i]; logger.debug(TAG, + * mbat); */ final String nm0 = new String(mba, StandardCharsets.UTF_8); diff --git a/otp/src/test/java/org/openjax/security/otp/GAuthTest.java b/otp/src/test/java/org/openjax/security/otp/GAuthTest.java index 18940a6..ec5a624 100644 --- a/otp/src/test/java/org/openjax/security/otp/GAuthTest.java +++ b/otp/src/test/java/org/openjax/security/otp/GAuthTest.java @@ -28,7 +28,7 @@ public class GAuthTest { private static void test(final String account, final String issuer) { final String secretKey = GAuth.generateRandomSecretKey(); final String barCode = GAuth.getBarCode(secretKey, account, issuer); - if (logger.isInfoEnabled()) logger.info("open \"https://codepen.io/davidshimjs/pen/NdBYrg\"\n" + barCode); + if (logger.isInfoEnabled()) { logger.info("open \"https://codepen.io/davidshimjs/pen/NdBYrg\"\n" + barCode); } // FIXME: This test can break, because the TOTP code changes every 30 // FIXME: seconds, and the test can by chance happen to cross this moment.