你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

IKey 接口

public interface IKey

用于使用 Microsoft Azure 密钥保管库 库表示加密密钥的接口。

方法摘要

修饰符和类型 方法和描述
ListenableFuture<byte[]> decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm)

解密指定的密码文本。 请注意,并非所有算法都需要或支持所有参数。

ListenableFuture<Triple<byte[], byte[], String>> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm)

加密指定的纯文本。 请注意,并非所有算法都需要或支持所有参数。

String getDefaultEncryptionAlgorithm()

此密钥的默认加密算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

String getDefaultKeyWrapAlgorithm()

此密钥的默认密钥换行算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

String getDefaultSignatureAlgorithm()

此密钥的默认签名算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

String getKid()

此密钥的唯一密钥标识符。

ListenableFuture<Pair<byte[], String>> signAsync(final byte[] digest, final String algorithm)

使用指定的算法对指定的摘要进行签名,如果未指定算法,则为键 DefaultSignatureAlgorithm 签名。

ListenableFuture<byte[]> unwrapKeyAsync(final byte[] encryptedKey, final String algorithm)

解包 (解密) 指定的加密密钥材料。

ListenableFuture<Boolean> verifyAsync(final byte[] digest, final byte[] signature, final String algorithm)

使用提供的摘要和算法验证提供的签名值。

ListenableFuture<Pair<byte[], String>> wrapKeyAsync(final byte[] key, final String algorithm)

包装 (使用指定的算法) 指定的对称密钥材料进行加密,如果未指定,则包装默认密钥WrapAlgorithm。

方法详细信息

decryptAsync

public ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm)

解密指定的密码文本。 请注意,并非所有算法都需要或支持所有参数。

参数:

ciphertext - 要解密的密码文本
iv - 初始化向量 (可选的某些算法)
authenticationData - 其他身份验证数据 (可选的某些算法)
authenticationTag - 加密操作中的身份验证标记 (可选,某些算法)
algorithm - 必须提供要使用的加密算法

返回:

包含纯文本的 ListenableFuture

引发:

NoSuchAlgorithmException - 算法无效

encryptAsync

public ListenableFuture> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm)

加密指定的纯文本。 请注意,并非所有算法都需要或支持所有参数。

参数:

plaintext - 要加密的纯文本
iv - 初始化向量 (可选的某些算法)
authenticationData - 其他身份验证数据 (可选的某些算法)
algorithm - 要使用的加密算法,默认为密钥 DefaultEncryptionAlgorithm

返回:

包含密码文本、身份验证标记和所用算法的 ListenableFuture

引发:

NoSuchAlgorithmException - 算法无效

getDefaultEncryptionAlgorithm

public String getDefaultEncryptionAlgorithm()

此密钥的默认加密算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

返回:

此密钥的默认加密算法。

getDefaultKeyWrapAlgorithm

public String getDefaultKeyWrapAlgorithm()

此密钥的默认密钥换行算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

返回:

此密钥的默认密钥换行算法。

getDefaultSignatureAlgorithm

public String getDefaultSignatureAlgorithm()

此密钥的默认签名算法,使用 Json Web 密钥算法中的表示形式,RFC7513。

返回:

此密钥的默认签名算法。

getKid

public String getKid()

此密钥的唯一密钥标识符。

返回:

密钥标识符

signAsync

public ListenableFuture> signAsync(final byte[] digest, final String algorithm)

使用指定的算法对指定的摘要进行签名,如果未指定算法,则为键 DefaultSignatureAlgorithm 签名。

参数:

digest - 要签名的摘要
algorithm - 要使用的签名算法

返回:

包含签名和所用算法的 ListenableFuture。

引发:

NoSuchAlgorithmException - 算法无效

unwrapKeyAsync

public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm)

解包 (解密) 指定的加密密钥材料。

参数:

encryptedKey - 要解密的加密密钥
algorithm - 必须提供要使用的算法

返回:

包含未包装密钥的 ListenableFuture

引发:

NoSuchAlgorithmException - 算法无效

verifyAsync

public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm)

使用提供的摘要和算法验证提供的签名值。

参数:

digest - 摘要输入
signature - 要验证的签名
algorithm - 必须提供要使用的算法

返回:

包含签名和所用算法的 ListenableFuture。

引发:

NoSuchAlgorithmException - 算法无效

wrapKeyAsync

public ListenableFuture> wrapKeyAsync(final byte[] key, final String algorithm)

包装 (使用指定的算法) 指定的对称密钥材料进行加密,如果未指定,则包装默认密钥WrapAlgorithm。

参数:

key - 要包装的对称密钥
algorithm - 要使用的包装算法,默认为键 DefaultKeyWrapAlgorithm

返回:

ListenableFuture 包含加密密钥和使用的算法

引发:

NoSuchAlgorithmException - 算法无效

适用于