diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/KeyFilter.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/KeyFilter.java index 3d1f104a..e98c3225 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/KeyFilter.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/KeyFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import java.util.HashSet; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPainless.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPainless.java index 4870f1bb..d47522c5 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPainless.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPainless.java @@ -1,12 +1,31 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import java.io.ByteArrayInputStream; import java.io.IOException; +import de.vanitasvitae.crypto.pgpainless.algorithm.CompressionAlgorithm; +import de.vanitasvitae.crypto.pgpainless.algorithm.SymmetricKeyAlgorithm; import de.vanitasvitae.crypto.pgpainless.decryption_verification.DecryptionBuilder; import de.vanitasvitae.crypto.pgpainless.encryption_signing.EncryptionBuilder; import de.vanitasvitae.crypto.pgpainless.key.generation.KeyRingBuilder; +import de.vanitasvitae.crypto.pgpainless.symmetric_encryption.SymmetricEncryptorDecryptor; import org.bouncycastle.bcpg.ArmoredInputStream; +import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; @@ -27,4 +46,33 @@ public class PGPainless { public static PGPPublicKeyRing publicKeyRingFromBytes(byte[] bytes) throws IOException { return new PGPPublicKeyRing(new ArmoredInputStream(new ByteArrayInputStream(bytes)), new BcKeyFingerprintCalculator()); } + + /** + * Encrypt some data symmetrically using OpenPGP and a password. + * The resulting data will be uncompressed and integrity protected. + * + * @param data input data. + * @param password password. + * @return symmetrically OpenPGP encrypted data. + * @throws IOException IO is dangerous. + * @throws PGPException PGP is brittle. + */ + public static byte[] encryptWithPassword(byte[] data, char[] password, SymmetricKeyAlgorithm algorithm) throws IOException, PGPException { + return SymmetricEncryptorDecryptor.symmetricallyEncrypt(data, password, + algorithm, CompressionAlgorithm.UNCOMPRESSED); + } + + /** + * Decrypt some symmetrically encrypted data using a password. + * The data is suspected to be integrity protected. + * + * @param data symmetrically OpenPGP encrypted data. + * @param password password. + * @return decrypted data. + * @throws IOException IO is dangerous. + * @throws PGPException PGP is brittle. + */ + public static byte[] decryptWithPassword(byte[] data, char[] password) throws IOException, PGPException { + return SymmetricEncryptorDecryptor.symmetricallyDecrypt(data, password); + } } diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPv4Fingerprint.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPv4Fingerprint.java index 888b7834..e607860f 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPv4Fingerprint.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/PGPv4Fingerprint.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import java.util.Arrays; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/PainlessStream.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/PainlessStream.java index 067459a8..116cc1c0 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/PainlessStream.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/PainlessStream.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/PublicKeyNotFoundException.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/PublicKeyNotFoundException.java index c6e74650..659d3b9a 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/PublicKeyNotFoundException.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/PublicKeyNotFoundException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import org.bouncycastle.openpgp.PGPException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/SecretKeyNotFoundException.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/SecretKeyNotFoundException.java index cee61f5a..07e86653 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/SecretKeyNotFoundException.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/SecretKeyNotFoundException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; public class SecretKeyNotFoundException extends Exception { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/AlgorithmSuite.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/AlgorithmSuite.java index 24a0ba9e..fe1b4505 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/AlgorithmSuite.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/AlgorithmSuite.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.ArrayList; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/CompressionAlgorithm.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/CompressionAlgorithm.java index 6408af7c..4694abde 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/CompressionAlgorithm.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/CompressionAlgorithm.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.HashMap; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/Feature.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/Feature.java index e74103f7..da0e2ca6 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/Feature.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/Feature.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.HashMap; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/HashAlgorithm.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/HashAlgorithm.java index 7cf74670..5fcb2955 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/HashAlgorithm.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/HashAlgorithm.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.HashMap; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/KeyFlag.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/KeyFlag.java index e1d365a4..9e626d49 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/KeyFlag.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/KeyFlag.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import org.bouncycastle.bcpg.sig.KeyFlags; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/PublicKeyAlgorithm.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/PublicKeyAlgorithm.java index a436c223..286b080a 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/PublicKeyAlgorithm.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/PublicKeyAlgorithm.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.HashMap; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/SymmetricKeyAlgorithm.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/SymmetricKeyAlgorithm.java index 51993eb7..ec5cec80 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/SymmetricKeyAlgorithm.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/algorithm/SymmetricKeyAlgorithm.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.algorithm; import java.util.HashMap; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilder.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilder.java index c4acbfa6..7688cdec 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilder.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilderInterface.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilderInterface.java index b820bbae..062c498e 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilderInterface.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionBuilderInterface.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStream.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStream.java index 3efb3bdb..c3534429 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStream.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStream.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java index 84673a2d..772658e7 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/MissingPublicKeyCallback.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/MissingPublicKeyCallback.java index 7fe238a8..42b4c9a3 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/MissingPublicKeyCallback.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/MissingPublicKeyCallback.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; public interface MissingPublicKeyCallback { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/PainlessResult.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/PainlessResult.java index 56534239..ab87010d 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/PainlessResult.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/PainlessResult.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.util.Collections; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/SignatureVerifyingInputStream.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/SignatureVerifyingInputStream.java index 975b5a44..6d81fc86 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/SignatureVerifyingInputStream.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/SignatureVerifyingInputStream.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.decryption_verification; import java.io.FilterInputStream; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilder.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilder.java index 552756d8..aff78b2e 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilder.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.encryption_signing; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilderInterface.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilderInterface.java index 1c32f106..48e063ef 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilderInterface.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionBuilderInterface.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.encryption_signing; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionStream.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionStream.java index 5628aae8..857bedf6 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionStream.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/encryption_signing/EncryptionStream.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.encryption_signing; import java.io.IOException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/SecretKeyRingProtector.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/SecretKeyRingProtector.java index cc9d445f..6aa3cadd 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/SecretKeyRingProtector.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/SecretKeyRingProtector.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; @@ -5,8 +20,8 @@ import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor; public interface SecretKeyRingProtector { - PBESecretKeyDecryptor getDecryptor(Long keyId); + PBESecretKeyDecryptor getDecryptor(Long keyId); - PBESecretKeyEncryptor getEncryptor(Long keyId); + PBESecretKeyEncryptor getEncryptor(Long keyId); } diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/UnprotectedKeysProtector.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/UnprotectedKeysProtector.java index d5828abd..ca04a0d3 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/UnprotectedKeysProtector.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/UnprotectedKeysProtector.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilder.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilder.java index 69a6b59b..c46b14fa 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilder.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilderInterface.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilderInterface.java index 31f177fa..12e12649 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilderInterface.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeyRingBuilderInterface.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation; import java.security.InvalidAlgorithmParameterException; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpec.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpec.java index db081ca2..60054d8d 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpec.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpec.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation; import de.vanitasvitae.crypto.pgpainless.key.generation.type.KeyType; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilder.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilder.java index 6f69711f..1df26092 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilder.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation; import de.vanitasvitae.crypto.pgpainless.algorithm.AlgorithmSuite; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilderInterface.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilderInterface.java index 56d836fc..3089a7d9 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilderInterface.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/KeySpecBuilderInterface.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation; import de.vanitasvitae.crypto.pgpainless.algorithm.CompressionAlgorithm; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDH.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDH.java index c04b6e77..0e6b905a 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDH.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDH.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import java.security.spec.AlgorithmParameterSpec; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDSA.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDSA.java index 8ada8c54..0acf5cf0 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDSA.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ECDSA.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import de.vanitasvitae.crypto.pgpainless.algorithm.PublicKeyAlgorithm; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_ENCRYPT.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_ENCRYPT.java index 72fdaa06..f0227c3e 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_ENCRYPT.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_ENCRYPT.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import de.vanitasvitae.crypto.pgpainless.algorithm.PublicKeyAlgorithm; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_GENERAL.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_GENERAL.java index b1d19c68..e64800e9 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_GENERAL.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/ElGamal_GENERAL.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import java.security.spec.AlgorithmParameterSpec; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/KeyType.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/KeyType.java index c05c4359..1de41170 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/KeyType.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/KeyType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import java.security.spec.AlgorithmParameterSpec; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_ENCRYPT.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_ENCRYPT.java index 13d53957..53b90e1e 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_ENCRYPT.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_ENCRYPT.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import de.vanitasvitae.crypto.pgpainless.algorithm.PublicKeyAlgorithm; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_GENERAL.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_GENERAL.java index 72c1ea7e..48c87971 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_GENERAL.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_GENERAL.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import java.security.spec.AlgorithmParameterSpec; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_SIGN.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_SIGN.java index 7f6ff32c..cac29355 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_SIGN.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/RSA_SIGN.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type; import de.vanitasvitae.crypto.pgpainless.algorithm.PublicKeyAlgorithm; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/curve/EllipticCurve.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/curve/EllipticCurve.java index 2b1db055..dfd906b8 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/curve/EllipticCurve.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/curve/EllipticCurve.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type.curve; public enum EllipticCurve { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/DiffieHellmanLength.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/DiffieHellmanLength.java index 87575da3..67111002 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/DiffieHellmanLength.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/DiffieHellmanLength.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type.length; public enum DiffieHellmanLength implements KeyLength { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/ElGamalLength.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/ElGamalLength.java index 09561a90..da8e7539 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/ElGamalLength.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/ElGamalLength.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type.length; public enum ElGamalLength implements KeyLength { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/KeyLength.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/KeyLength.java index 924ed50d..6ce30779 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/KeyLength.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/KeyLength.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type.length; public interface KeyLength { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/RsaLength.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/RsaLength.java index 7a8d9a0c..f35f8b83 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/RsaLength.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/generation/type/length/RsaLength.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.generation.type.length; public enum RsaLength implements KeyLength { diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/KeySelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/KeySelectionStrategy.java index ce9f4aef..ebea2c2d 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/KeySelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/KeySelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key; import java.util.Set; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/PublicKeySelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/PublicKeySelectionStrategy.java index 5c36717a..6627c081 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/PublicKeySelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/PublicKeySelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key; import java.util.HashSet; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/SecretKeySelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/SecretKeySelectionStrategy.java index e364f5d1..d1cab597 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/SecretKeySelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/SecretKeySelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key; import java.util.HashSet; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/And.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/And.java index 50f91338..dfa5a2af 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/And.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/And.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key.impl; import de.vanitasvitae.crypto.pgpainless.key.selection.key.PublicKeySelectionStrategy; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/EncryptionKeySelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/EncryptionKeySelectionStrategy.java index 48205939..298d1a73 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/EncryptionKeySelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/EncryptionKeySelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key.impl; import de.vanitasvitae.crypto.pgpainless.key.selection.key.PublicKeySelectionStrategy; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/NoRevocation.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/NoRevocation.java index a1310eb3..c9cb3ea8 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/NoRevocation.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/NoRevocation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key.impl; import de.vanitasvitae.crypto.pgpainless.key.selection.key.PublicKeySelectionStrategy; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/SignatureKeySelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/SignatureKeySelectionStrategy.java index 27ca0a95..6defe990 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/SignatureKeySelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/key/impl/SignatureKeySelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.key.impl; import de.vanitasvitae.crypto.pgpainless.key.selection.key.SecretKeySelectionStrategy; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/KeyRingSelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/KeyRingSelectionStrategy.java index 9daf2eed..0f168829 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/KeyRingSelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/KeyRingSelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring; import java.util.Set; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/PublicKeyRingSelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/PublicKeyRingSelectionStrategy.java index fca0760f..af5bced9 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/PublicKeyRingSelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/PublicKeyRingSelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring; import java.util.HashSet; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/SecretKeyRingSelectionStrategy.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/SecretKeyRingSelectionStrategy.java index 73b25995..6564e43a 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/SecretKeyRingSelectionStrategy.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/SecretKeyRingSelectionStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring; import java.util.HashSet; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Email.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Email.java index 68357b63..824b925e 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Email.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Email.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import org.bouncycastle.openpgp.PGPPublicKey; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/ExactUserId.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/ExactUserId.java index 636bf9fe..4851e5a6 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/ExactUserId.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/ExactUserId.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import java.util.Iterator; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/PartialUserId.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/PartialUserId.java index ddc55a20..2826f233 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/PartialUserId.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/PartialUserId.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import java.util.Iterator; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Whitelist.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Whitelist.java index b2838fc7..7b66108f 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Whitelist.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Whitelist.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import java.util.Map; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Wildcard.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Wildcard.java index f0df7b20..3891f37b 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Wildcard.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/Wildcard.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import de.vanitasvitae.crypto.pgpainless.key.selection.keyring.PublicKeyRingSelectionStrategy; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/XMPP.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/XMPP.java index 4062a4fa..c8fd5e75 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/XMPP.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/key/selection/keyring/impl/XMPP.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.key.selection.keyring.impl; import org.bouncycastle.openpgp.PGPPublicKeyRing; diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/symmetric_encryption/SymmetricEncryptorDecryptor.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/symmetric_encryption/SymmetricEncryptorDecryptor.java new file mode 100644 index 00000000..e68bc04e --- /dev/null +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/symmetric_encryption/SymmetricEncryptorDecryptor.java @@ -0,0 +1,149 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.vanitasvitae.crypto.pgpainless.symmetric_encryption; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.SecureRandom; +import java.util.Date; + +import de.vanitasvitae.crypto.pgpainless.algorithm.CompressionAlgorithm; +import de.vanitasvitae.crypto.pgpainless.algorithm.SymmetricKeyAlgorithm; +import org.bouncycastle.openpgp.PGPCompressedData; +import org.bouncycastle.openpgp.PGPCompressedDataGenerator; +import org.bouncycastle.openpgp.PGPEncryptedDataGenerator; +import org.bouncycastle.openpgp.PGPEncryptedDataList; +import org.bouncycastle.openpgp.PGPException; +import org.bouncycastle.openpgp.PGPLiteralData; +import org.bouncycastle.openpgp.PGPLiteralDataGenerator; +import org.bouncycastle.openpgp.PGPPBEEncryptedData; +import org.bouncycastle.openpgp.PGPUtil; +import org.bouncycastle.openpgp.bc.BcPGPObjectFactory; +import org.bouncycastle.openpgp.operator.bc.BcPBEDataDecryptorFactory; +import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider; +import org.bouncycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator; +import org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder; +import org.bouncycastle.util.io.Streams; + +/** + * Stolen from + * Bouncycastle examples. + */ +public class SymmetricEncryptorDecryptor { + + public static byte[] symmetricallyEncrypt(byte[] data, + char[] password, + SymmetricKeyAlgorithm algorithm, + CompressionAlgorithm compressionAlgorithm) + throws IOException, PGPException { + + byte[] compressedData = compress(data, compressionAlgorithm.getAlgorithmId()); + + ByteArrayOutputStream bOut = new ByteArrayOutputStream(); + + PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator( + new JcePGPDataEncryptorBuilder(algorithm.getAlgorithmId()) + .setWithIntegrityPacket(true) + .setSecureRandom(new SecureRandom()) + .setProvider("BC")); + + encGen.addMethod(new JcePBEKeyEncryptionMethodGenerator(password).setProvider("BC")); + + OutputStream encOut = encGen.open(bOut, compressedData.length); + + encOut.write(compressedData); + encOut.close(); + + return bOut.toByteArray(); + } + + public static byte[] symmetricallyDecrypt(byte[] data, char[] password) throws IOException, PGPException { + InputStream in = new BufferedInputStream(new ByteArrayInputStream(data)); + in = PGPUtil.getDecoderStream(in); + + BcPGPObjectFactory pgpF = new BcPGPObjectFactory(in); + PGPEncryptedDataList enc; + Object o = pgpF.nextObject(); + + if (o instanceof PGPEncryptedDataList) { + enc = (PGPEncryptedDataList) o; + } else { + enc = (PGPEncryptedDataList) pgpF.nextObject(); + } + + PGPPBEEncryptedData pbe = (PGPPBEEncryptedData) enc.get(0); + + InputStream clear = pbe.getDataStream(new BcPBEDataDecryptorFactory( + password, new BcPGPDigestCalculatorProvider())); + + + BcPGPObjectFactory pgpFact = new BcPGPObjectFactory(clear); + + o = pgpFact.nextObject(); + if (o instanceof PGPCompressedData) { + PGPCompressedData cData = (PGPCompressedData) o; + pgpFact = new BcPGPObjectFactory(cData.getDataStream()); + o = pgpFact.nextObject(); + } + + PGPLiteralData ld = (PGPLiteralData) o; + InputStream unc = ld.getInputStream(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + Streams.pipeAll(unc, outputStream); + + outputStream.close(); + + if (pbe.isIntegrityProtected()) { + if (!pbe.verify()) { + throw new PGPException("Integrity check failed."); + } + } else { + throw new PGPException("Symmetrically encrypted data is not integrity protected."); + } + + return outputStream.toByteArray(); + } + + private static byte[] compress(byte[] clearData, int algorithm) throws IOException + { + ByteArrayOutputStream bOut = new ByteArrayOutputStream(); + PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(algorithm); + OutputStream cos = comData.open(bOut); + + PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator(); + + OutputStream pOut = lData.open(cos, + PGPLiteralData.BINARY, + PGPLiteralDataGenerator.CONSOLE, + clearData.length, + new Date() + ); + + pOut.write(clearData); + pOut.close(); + + comData.close(); + + return bOut.toByteArray(); + } + +} diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/util/BCUtil.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/util/BCUtil.java index 327813c3..3f1d2e0a 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/util/BCUtil.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/util/BCUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.util; import java.io.IOException; @@ -42,8 +57,7 @@ public class BCUtil { PGPPublicKeyRing pubring = constructor.newInstance(list); return pubring; } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - e.printStackTrace(); - return null; + throw new AssertionError(e); } } } \ No newline at end of file diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/util/MultiMap.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/util/MultiMap.java index 52e090a3..a111d1d5 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/util/MultiMap.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/util/MultiMap.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless.util; import java.util.Collection; diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/AbstractPGPainlessTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/AbstractPGPainlessTest.java index 42d38766..2507149e 100644 --- a/src/test/java/de/vanitasvitae/crypto/pgpainless/AbstractPGPainlessTest.java +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/AbstractPGPainlessTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import java.security.Security; diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/BCUtilTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/BCUtilTest.java index f81dea02..941fd8b8 100644 --- a/src/test/java/de/vanitasvitae/crypto/pgpainless/BCUtilTest.java +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/BCUtilTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import static junit.framework.TestCase.assertEquals; @@ -19,9 +34,8 @@ public class BCUtilTest extends AbstractPGPainlessTest { @Test public void test() - throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, - IOException { - PGPSecretKeyRing sec = PGPainless.generateKeyRing().simpleEcKeyRing("Hallo Welt"); + throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { + PGPSecretKeyRing sec = PGPainless.generateKeyRing().simpleEcKeyRing("donald@duck.tails"); PGPPublicKeyRing pub = BCUtil.publicKeyRingFromSecretKeyRing(sec); int secSize = 0; diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/EncryptDecryptTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/EncryptDecryptTest.java index ac47cf3e..1329c8b5 100644 --- a/src/test/java/de/vanitasvitae/crypto/pgpainless/EncryptDecryptTest.java +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/EncryptDecryptTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import static junit.framework.TestCase.assertTrue; @@ -15,6 +30,7 @@ import java.util.Collections; import java.util.logging.Level; import java.util.logging.Logger; +import de.vanitasvitae.crypto.pgpainless.algorithm.PublicKeyAlgorithm; import de.vanitasvitae.crypto.pgpainless.decryption_verification.DecryptionStream; import de.vanitasvitae.crypto.pgpainless.decryption_verification.PainlessResult; import de.vanitasvitae.crypto.pgpainless.key.SecretKeyRingProtector; @@ -30,8 +46,20 @@ import org.junit.Test; public class EncryptDecryptTest extends AbstractPGPainlessTest { + private static final Logger LOGGER = Logger.getLogger(EncryptDecryptTest.class.getName()); private static final Charset UTF8 = Charset.forName("UTF-8"); + private static final String testMessage = "Ah, Juliet, if the measure of thy joy\n" + + "Be heaped like mine, and that thy skill be more\n" + + "To blazon it, then sweeten with thy breath\n" + + "This neighbor air, and let rich music’s tongue\n" + + "Unfold the imagined happiness that both\n" + + "Receive in either by this dear encounter."; + + public EncryptDecryptTest() { + LOGGER.log(Level.INFO, "Plain Length: " + testMessage.getBytes(UTF8).length); + } + @Test public void freshKeysRsaToRsaTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, @@ -80,12 +108,7 @@ public class EncryptDecryptTest extends AbstractPGPainlessTest { SecretKeyRingProtector keyDecryptor = new UnprotectedKeysProtector(); - byte[] secretMessage = ("Ah, Juliet, if the measure of thy joy\n" + - "Be heaped like mine, and that thy skill be more\n" + - "To blazon it, then sweeten with thy breath\n" + - "This neighbor air, and let rich music’s tongue\n" + - "Unfold the imagined happiness that both\n" + - "Receive in either by this dear encounter.").getBytes(UTF8); + byte[] secretMessage = (testMessage).getBytes(UTF8); ByteArrayOutputStream envelope = new ByteArrayOutputStream(); @@ -100,6 +123,10 @@ public class EncryptDecryptTest extends AbstractPGPainlessTest { encryptor.close(); byte[] encryptedSecretMessage = envelope.toByteArray(); + LOGGER.log(Level.INFO, "Sender: " + PublicKeyAlgorithm.fromId(sender.getPublicKey().getAlgorithm()) + + " Receiver: " + PublicKeyAlgorithm.fromId(recipient.getPublicKey().getAlgorithm()) + + " Encrypted Length: " + encryptedSecretMessage.length); + // Juliet trieth to comprehend Romeos words ByteArrayInputStream envelopeIn = new ByteArrayInputStream(encryptedSecretMessage); diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/LengthTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/LengthTest.java new file mode 100644 index 00000000..364b60c0 --- /dev/null +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/LengthTest.java @@ -0,0 +1,127 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.vanitasvitae.crypto.pgpainless; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.security.InvalidAlgorithmParameterException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +import de.vanitasvitae.crypto.pgpainless.key.SecretKeyRingProtector; +import de.vanitasvitae.crypto.pgpainless.key.UnprotectedKeysProtector; +import de.vanitasvitae.crypto.pgpainless.key.generation.type.length.RsaLength; +import de.vanitasvitae.crypto.pgpainless.util.BCUtil; +import org.bouncycastle.openpgp.PGPException; +import org.bouncycastle.openpgp.PGPPublicKeyRing; +import org.bouncycastle.openpgp.PGPSecretKeyRing; +import org.bouncycastle.util.io.Streams; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Class used to determine the length of cipher-text depending on used algorithms. + */ +public class LengthTest extends AbstractPGPainlessTest { + + private static final Logger LOGGER = Logger.getLogger(LengthTest.class.getName()); + + //@Test + public void ecEc() + throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, + IOException { + LOGGER.log(Level.INFO, "\nEC -> EC"); + PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("simplejid@server.tld"); + PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("otherjid@other.srv"); + encryptDecryptForSecretKeyRings(sender, recipient); + } + + + //@Test + public void RsaRsa() + throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, + IOException { + LOGGER.log(Level.INFO, "\nRSA-2048 -> RSA-2048"); + PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("simplejid@server.tld", RsaLength._2048); + PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("otherjid@other.srv", RsaLength._2048); + encryptDecryptForSecretKeyRings(sender, recipient); + } + + //@Test + public void RsaRsa4096() + throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, + IOException { + LOGGER.log(Level.INFO, "\nRSA-4096 -> RSA-4096"); + PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("simplejid@server.tld", RsaLength._4096); + PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("otherjid@other.srv", RsaLength._4096); + encryptDecryptForSecretKeyRings(sender, recipient); + } + + //@Test + public void rsaEc() throws PGPException, IOException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, + NoSuchProviderException { + LOGGER.log(Level.INFO, "\nRSA-2048 -> EC"); + PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("simplejid@server.tld", RsaLength._2048); + PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("otherjid@other.srv"); + encryptDecryptForSecretKeyRings(sender, recipient); + } + + //@Test + public void ecRsa() + throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, + IOException { + LOGGER.log(Level.INFO, "\nEC -> RSA-2048"); + PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("simplejid@server.tld"); + PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("otherjid@other.srv", RsaLength._2048); + encryptDecryptForSecretKeyRings(sender, recipient); + } + + @Ignore + private void encryptDecryptForSecretKeyRings(PGPSecretKeyRing sender, PGPSecretKeyRing recipient) + throws PGPException, + IOException { + PGPPublicKeyRing recipientPub = BCUtil.publicKeyRingFromSecretKeyRing(recipient); + PGPPublicKeyRing senderPub = BCUtil.publicKeyRingFromSecretKeyRing(sender); + + SecretKeyRingProtector keyDecryptor = new UnprotectedKeysProtector(); + + for (int i = 1; i <= 100; i++) { + byte[] secretMessage = new byte[i * 20]; + new Random().nextBytes(secretMessage); + + ByteArrayOutputStream envelope = new ByteArrayOutputStream(); + + OutputStream encryptor = PGPainless.createEncryptor() + .onOutputStream(envelope) + .toRecipients(recipientPub) + //.doNotEncrypt() + .usingSecureAlgorithms() + .signWith(keyDecryptor, sender) + .noArmor(); + + Streams.pipeAll(new ByteArrayInputStream(secretMessage), encryptor); + encryptor.close(); + byte[] encryptedSecretMessage = envelope.toByteArray(); + + LOGGER.log(Level.INFO,"\n" + encryptedSecretMessage.length); + } + } +} diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/SymmetricTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/SymmetricTest.java new file mode 100644 index 00000000..13b19baf --- /dev/null +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/SymmetricTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.vanitasvitae.crypto.pgpainless; + +import static junit.framework.TestCase.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import de.vanitasvitae.crypto.pgpainless.algorithm.SymmetricKeyAlgorithm; +import org.bouncycastle.bcpg.ArmoredOutputStream; +import org.bouncycastle.openpgp.PGPException; +import org.junit.Test; + +public class SymmetricTest extends AbstractPGPainlessTest { + + private static final String message = "I grew up with the understanding that the world " + + "I lived in was one where people enjoyed a sort of freedom " + + "to communicate with each other in privacy, without it " + + "being monitored, without it being measured or analyzed " + + "or sort of judged by these shadowy figures or systems, " + + "any time they mention anything that travels across " + + "public lines.\n" + + "\n" + + "- Edward Snowden -"; + + @Test + public void testSymmetricEncryptionDecryption() throws IOException, PGPException { + byte[] plain = message.getBytes(); + byte[] enc = PGPainless.encryptWithPassword(plain, "choose_a_better_password_please".toCharArray(), SymmetricKeyAlgorithm.AES_128); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ArmoredOutputStream armor = new ArmoredOutputStream(out); + armor.write(enc); + armor.flush(); + armor.close(); + + // Print cipher text for validation with GnuPG. + System.out.println(new String(out.toByteArray())); + + byte[] plain2 = PGPainless.decryptWithPassword(enc, "choose_a_better_password_please".toCharArray()); + assertTrue(Arrays.equals(plain, plain2)); + } +} diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeys.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeys.java index 1b0980b4..91b81063 100644 --- a/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeys.java +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeys.java @@ -1,5 +1,4 @@ -/** - * +/* * Copyright 2018 Paul Schaub. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeysTest.java b/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeysTest.java index 01ac619f..a2be05d4 100644 --- a/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeysTest.java +++ b/src/test/java/de/vanitasvitae/crypto/pgpainless/TestKeysTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2018 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.vanitasvitae.crypto.pgpainless; import static junit.framework.TestCase.assertEquals;