diff --git a/.travis.yml b/.travis.yml index 8f125be..261e9ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,14 +14,14 @@ before_install: - tar xvf secrets.tar script: - - mvn clean install -X -Djarsigner.skip=false + - mvn clean install -X -Djarsigner.skip=false checkstyle:check after_success: - mvn test jacoco:report coveralls:report deploy: - provider: script - script: mvn -s ci-settings.xml deploy -X + script: mvn -s ci-settings.xml deploy -X checkstyle:checkstyle skip_cleanup: true on: branch: master diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7942123 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing to HKDF + +We ❤ pull requests from everyone. + +If possible proof features and bugfixes with unit tests. +This repo validates against checkstyle (import the xml found in the root to your IDE if possible) + +To run the tests (and checkstyle): + +```shell +mvn test checkstyle:check +``` + +Tests are automatically run against branches and pull requests +via TravisCI, so you can also depend on that. \ No newline at end of file diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..a5b63aa --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index d840e98..8ab5e1b 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,21 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + checkstyle.xml + + + + com.puppycrawl.tools + checkstyle + 8.4 + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/at/favre/lib/crypto/HKDF.java b/src/main/java/at/favre/lib/crypto/HKDF.java index 0524dc6..fbb6e64 100644 --- a/src/main/java/at/favre/lib/crypto/HKDF.java +++ b/src/main/java/at/favre/lib/crypto/HKDF.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package at.favre.lib.crypto; import javax.crypto.Mac; import java.nio.ByteBuffer; - /** * A standards-compliant implementation of RFC 5869 * for HMAC-based Key Derivation Function. @@ -44,6 +44,7 @@ * The HKDF Scheme * @see Wikipedia: HKDF */ +@SuppressWarnings("WeakerAccess") public final class HKDF { /** * Cache instances @@ -276,4 +277,4 @@ byte[] execute(byte[] pseudoRandomKey, byte[] info, int outLengthBytes) { return buffer.array(); } } -} \ No newline at end of file +} diff --git a/src/main/java/at/favre/lib/crypto/HkdfMacFactory.java b/src/main/java/at/favre/lib/crypto/HkdfMacFactory.java index d2b43ea..4572bc2 100644 --- a/src/main/java/at/favre/lib/crypto/HkdfMacFactory.java +++ b/src/main/java/at/favre/lib/crypto/HkdfMacFactory.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package at.favre.lib.crypto; import javax.crypto.Mac; diff --git a/src/test/java/at/favre/lib/crypto/HKDFBenchmarkTest.java b/src/test/java/at/favre/lib/crypto/HKDFBenchmarkTest.java index 18266d0..7677892 100644 --- a/src/test/java/at/favre/lib/crypto/HKDFBenchmarkTest.java +++ b/src/test/java/at/favre/lib/crypto/HKDFBenchmarkTest.java @@ -57,4 +57,4 @@ public void benchmark() throws Exception { System.out.println("Run (" + entry.getKey() + "): " + entry.getValue() + "ns"); } } -} \ No newline at end of file +} diff --git a/src/test/java/at/favre/lib/crypto/HKDFTest.java b/src/test/java/at/favre/lib/crypto/HKDFTest.java index fc69210..d8ce0f0 100644 --- a/src/test/java/at/favre/lib/crypto/HKDFTest.java +++ b/src/test/java/at/favre/lib/crypto/HKDFTest.java @@ -36,7 +36,8 @@ public void quickStarTest() throws Exception { @Test public void simpleUseCase() throws Exception { //if no dynamic salt is available, a static salt is better than null - byte[] staticSalt32Byte = new byte[]{(byte) 0xDA, (byte) 0xAC, 0x3E, 0x10, 0x55, (byte) 0xB5, (byte) 0xF1, 0x3E, 0x53, (byte) 0xE4, 0x70, (byte) 0xA8, 0x77, 0x79, (byte) 0x8E, 0x0A, (byte) 0x89, (byte) 0xAE, (byte) 0x96, 0x5F, 0x19, 0x5D, 0x53, 0x62, 0x58, (byte) 0x84, 0x2C, 0x09, (byte) 0xAD, 0x6E, 0x20, (byte) 0xD4}; + byte[] staticSalt32Byte = new byte[]{(byte) 0xDA, (byte) 0xAC, 0x3E, 0x10, 0x55, (byte) 0xB5, (byte) 0xF1, 0x3E, 0x53, (byte) 0xE4, 0x70, (byte) 0xA8, 0x77, 0x79, (byte) 0x8E, 0x0A, (byte) + 0x89, (byte) 0xAE, (byte) 0x96, 0x5F, 0x19, 0x5D, 0x53, 0x62, 0x58, (byte) 0x84, 0x2C, 0x09, (byte) 0xAD, 0x6E, 0x20, (byte) 0xD4}; //example input String userInput = "this is a user input with bad entropy"; @@ -237,5 +238,4 @@ public void run() { executorService.shutdown(); executorService.awaitTermination(10, TimeUnit.SECONDS); } - -} \ No newline at end of file +} diff --git a/src/test/java/at/favre/lib/crypto/HkdfMacFactoryTest.java b/src/test/java/at/favre/lib/crypto/HkdfMacFactoryTest.java index 5bdc706..38dfb25 100644 --- a/src/test/java/at/favre/lib/crypto/HkdfMacFactoryTest.java +++ b/src/test/java/at/favre/lib/crypto/HkdfMacFactoryTest.java @@ -52,4 +52,4 @@ private void testHmacFactory(HkdfMacFactory macFactory, int refLength) { byte[] hash = mac.doFinal(); assertEquals(refLength, hash.length); } -} \ No newline at end of file +} diff --git a/src/test/java/at/favre/lib/crypto/RFC5869TestCases.java b/src/test/java/at/favre/lib/crypto/RFC5869TestCases.java index 2aefc26..f2d14a9 100644 --- a/src/test/java/at/favre/lib/crypto/RFC5869TestCases.java +++ b/src/test/java/at/favre/lib/crypto/RFC5869TestCases.java @@ -158,4 +158,4 @@ private void checkStep2(HkdfMacFactory macFactory, String prk, String info, int Hex.decodeHex(info.toCharArray()), l); assertArrayEquals(Hex.decodeHex(okm.toCharArray()), currentOkm); } -} \ No newline at end of file +}