Skip to content

Commit

Permalink
Merge pull request #1 from Azure/master
Browse files Browse the repository at this point in the history
Update for changes.
  • Loading branch information
alvadb committed Sep 19, 2016
2 parents ee6dcc1 + 990d184 commit 1c05188
Show file tree
Hide file tree
Showing 120 changed files with 9,096 additions and 7,074 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/**
*
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* 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.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.keyvault.core;
Expand Down Expand Up @@ -153,7 +141,7 @@ public interface IKey extends Closeable {
* The signature to verify
* @param algorithm
* The algorithm to use, must be provided
* @return A ListenableFuture containing a boolean result
* @return A ListenableFuture containing the signature and the algorithm used.
* @throws NoSuchAlgorithmException the algorithm is not valid
*/
ListenableFuture<Boolean> verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException;
Expand Down
55 changes: 30 additions & 25 deletions azure-keyvault-cryptography/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,35 @@
<tag>HEAD</tag>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<legal>
<![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
<checkstyle.skip>true</checkstyle.skip>
</properties>


<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<scope>test</scope>
<version>1.54</version>
</dependency>
<dependency>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<legal>
<![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
<checkstyle.skip>true</checkstyle.skip>
</properties>


<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<scope>test</scope>
<version>1.54</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>azure-keyvault-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>azure-keyvault-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<artifactId>azure-keyvault-webkey</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
/**
*
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* 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.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.keyvault.cryptography;

/**
* Abstract base class for all Algorithm objects.
*
*/
public abstract class Algorithm {

private final String _name;

/**
* Constructor.
*
* @param name The name of the algorithm.
*/
protected Algorithm(String name) {
if (Strings.isNullOrEmpty(name)) {
if (Strings.isNullOrWhiteSpace(name)) {
throw new IllegalArgumentException("name");
}

_name = name;
}

/**
* Gets the name of the algorithm.
*
* @return The name of the algorithm.
*/
public String getName() {
return _name;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/**
*
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* 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.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.keyvault.cryptography;
Expand All @@ -30,6 +18,7 @@
import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128;
import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192;
import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256;
import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256;
import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15;
import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep;

Expand All @@ -38,46 +27,53 @@ public class AlgorithmResolver {
public static final AlgorithmResolver Default = new AlgorithmResolver();

static {
Default.put(Aes128CbcHmacSha256.AlgorithmName, new Aes128CbcHmacSha256());
Default.put(Aes192CbcHmacSha384.AlgorithmName, new Aes192CbcHmacSha384());
Default.put(Aes256CbcHmacSha512.AlgorithmName, new Aes256CbcHmacSha512());
Default.put(Aes128CbcHmacSha256.ALGORITHM_NAME, new Aes128CbcHmacSha256());
Default.put(Aes192CbcHmacSha384.ALGORITHM_NAME, new Aes192CbcHmacSha384());
Default.put(Aes256CbcHmacSha512.ALGORITHM_NAME, new Aes256CbcHmacSha512());

Default.put(Aes128Cbc.AlgorithmName, new Aes128Cbc());
Default.put(Aes192Cbc.AlgorithmName, new Aes192Cbc());
Default.put(Aes256Cbc.AlgorithmName, new Aes256Cbc());
Default.put(Aes128Cbc.ALGORITHM_NAME, new Aes128Cbc());
Default.put(Aes192Cbc.ALGORITHM_NAME, new Aes192Cbc());
Default.put(Aes256Cbc.ALGORITHM_NAME, new Aes256Cbc());

Default.put(AesKw128.AlgorithmName, new AesKw128());
Default.put(AesKw192.AlgorithmName, new AesKw192());
Default.put(AesKw256.AlgorithmName, new AesKw256());
Default.put(AesKw128.ALGORITHM_NAME, new AesKw128());
Default.put(AesKw192.ALGORITHM_NAME, new AesKw192());
Default.put(AesKw256.ALGORITHM_NAME, new AesKw256());

Default.put(Rsa15.AlgorithmName, new Rsa15());
Default.put(RsaOaep.AlgorithmName, new RsaOaep());
Default.put(Rsa15.ALGORITHM_NAME, new Rsa15());
Default.put(RsaOaep.ALGORITHM_NAME, new RsaOaep());

// Default.put( Rs256.AlgorithmName, new Rs256() );
// Default.put( RsNull.AlgorithmName, new RsNull() );
Default.put( Rs256.ALGORITHM_NAME, new Rs256() );
// Default.put( RsNull.ALGORITHM_NAME, new RsNull() );
}

private final ConcurrentMap<String, Algorithm> _algorithms = new ConcurrentHashMap<String, Algorithm>();

/// <summary>
/// Returns the implementation for an algorithm name
/// </summary>
/// <param name="algorithmName">The algorithm name</param>
/// <returns></returns>
/**
* Returns the implementation for an algorithm name.
*
* @param algorithmName The algorithm name.
* @return The implementation for the algorithm or null.
*/
public Algorithm get(String algorithmName) {
return _algorithms.get(algorithmName);
}

/**
* Add/Update a named algorithm implementation.
*
* @param algorithmName The algorithm name.
* @param provider The implementation of the algorithm.
*/
public void put(String algorithmName, Algorithm provider) {
_algorithms.put(algorithmName, provider);
}

/// <summary>
/// Removes an algorithm from the resolver
/// </summary>
/// <param name="algorithmName">The algorithm name</param>
/**
* Remove a named algorithm implementation.
*
* @param algorithmName The algorithm name
*/
public void remove(String algorithmName) {
_algorithms.remove(algorithmName);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/**
*
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* 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.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.keyvault.cryptography;
Expand All @@ -25,18 +13,74 @@

import javax.crypto.NoSuchPaddingException;

/**
* Abstract base class for all asymmetric encryption algorithms.
*
*/
public abstract class AsymmetricEncryptionAlgorithm extends EncryptionAlgorithm {

/**
* Constructor.
*
* @param name The name of the algorithm.
*/
protected AsymmetricEncryptionAlgorithm(String name) {
super(name);
}

/**
* Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that
* uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider.
*
* @param keyPair
* The key pair to use.
* @return
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException;

/**
* Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that
* uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}.
*
* @param keyPair
* The key pair to use.
* @param provider
* The provider to use.
* @return
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException;

/**
* Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that
* uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider.
*
* @param keyPair
* The key pair to use.
* @return
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException;

/**
* Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that
* uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}.
*
* @param keyPair
* The key pair to use.
* @param provider
* The provider to use.
* @return
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException;

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/**
*
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* 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.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.keyvault.cryptography;
Expand Down

0 comments on commit 1c05188

Please sign in to comment.