public class SymmetricKey extends Object implements IKey
| Modifier and Type | Field and Description |
|---|---|
static int |
DefaultKeySize |
static int |
KeySize128 |
static int |
KeySize192 |
static int |
KeySize256 |
static int |
KeySize384 |
static int |
KeySize512 |
| Constructor and Description |
|---|
SymmetricKey()
Creates a SymmetricKey with a random key identifier and
a random key with DefaultKeySize bits.
|
SymmetricKey(String kid)
Creates a SymmetricKey with the specified key identifier and
a random key with DefaultKeySize bits.
|
SymmetricKey(String kid,
byte[] keyBytes)
Creates a SymmetricKey with the specified key identifier and key material.
|
SymmetricKey(String kid,
byte[] keyBytes,
Provider provider)
Creates a SymmetricKey with the specified key identifier and key material
that uses the specified Provider.
|
SymmetricKey(String kid,
int keySizeInBytes)
Creates a SymmetricKey with the specified key identifier and
a random key with the specified size.
|
SymmetricKey(String kid,
int keySizeInBytes,
Provider provider)
Creates a SymmetricKey with the specified key identifier and
a random key with the specified size that uses the specified provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
com.google.common.util.concurrent.ListenableFuture<byte[]> |
decryptAsync(byte[] ciphertext,
byte[] iv,
byte[] authenticationData,
byte[] authenticationTag,
String algorithm) |
com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Triple<byte[],byte[],String>> |
encryptAsync(byte[] plaintext,
byte[] iv,
byte[] authenticationData,
String algorithm) |
String |
getDefaultEncryptionAlgorithm() |
String |
getDefaultKeyWrapAlgorithm() |
String |
getDefaultSignatureAlgorithm() |
String |
getKid() |
com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Pair<byte[],String>> |
signAsync(byte[] digest,
String algorithm) |
com.google.common.util.concurrent.ListenableFuture<byte[]> |
unwrapKeyAsync(byte[] encryptedKey,
String algorithm) |
com.google.common.util.concurrent.ListenableFuture<Boolean> |
verifyAsync(byte[] digest,
byte[] signature,
String algorithm) |
com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Pair<byte[],String>> |
wrapKeyAsync(byte[] key,
String algorithm) |
public static final int KeySize128
public static final int KeySize192
public static final int KeySize256
public static final int KeySize384
public static final int KeySize512
public static final int DefaultKeySize
public SymmetricKey()
public SymmetricKey(String kid)
kid - The key identifier to use.public SymmetricKey(String kid, int keySizeInBytes)
kid - The key identifier to use.keySizeInBytes - The key size to use in bytes.public SymmetricKey(String kid, int keySizeInBytes, Provider provider)
kid - The key identifier to use.keySizeInBytes - The key size to use in bytes.provider - The provider to use (optional, null for default)public SymmetricKey(String kid, byte[] keyBytes)
kid - The key identifier to use.keyBytes - The key material to use.public SymmetricKey(String kid, byte[] keyBytes, Provider provider)
kid - The key identifier to use.keyBytes - The key material to use.provider - The Provider to use (optional, null for default)public String getDefaultEncryptionAlgorithm()
getDefaultEncryptionAlgorithm in interface IKeypublic String getDefaultKeyWrapAlgorithm()
getDefaultKeyWrapAlgorithm in interface IKeypublic String getDefaultSignatureAlgorithm()
getDefaultSignatureAlgorithm in interface IKeypublic com.google.common.util.concurrent.ListenableFuture<byte[]> decryptAsync(byte[] ciphertext,
byte[] iv,
byte[] authenticationData,
byte[] authenticationTag,
String algorithm)
throws NoSuchAlgorithmException
decryptAsync in interface IKeyNoSuchAlgorithmExceptionpublic com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Triple<byte[],byte[],String>> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException
encryptAsync in interface IKeyNoSuchAlgorithmExceptionpublic com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Pair<byte[],String>> wrapKeyAsync(byte[] key, String algorithm) throws NoSuchAlgorithmException
wrapKeyAsync in interface IKeyNoSuchAlgorithmExceptionpublic com.google.common.util.concurrent.ListenableFuture<byte[]> unwrapKeyAsync(byte[] encryptedKey,
String algorithm)
throws NoSuchAlgorithmException
unwrapKeyAsync in interface IKeyNoSuchAlgorithmExceptionpublic com.google.common.util.concurrent.ListenableFuture<org.apache.commons.lang3.tuple.Pair<byte[],String>> signAsync(byte[] digest, String algorithm)
public com.google.common.util.concurrent.ListenableFuture<Boolean> verifyAsync(byte[] digest, byte[] signature, String algorithm)
verifyAsync in interface IKeypublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/