public class KeyChain extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
KeyChain.Error
A KeyChain.Error extends Exception and represents an error in KeyChain
processing.
|
static class |
KeyChain.InvalidSigningInfoError
A KeyChain.InvalidSigningInfoError extends KeyChain.Error to indicate
that the supplied SigningInfo is invalid.
|
static class |
KeyChain.LocatorMismatchError
A KeyChain.LocatorMismatchError extends KeyChain.Error to indicate that
the supplied TPM locator does not match the locator stored in the PIB.
|
static interface |
KeyChain.MakePibImpl |
static interface |
KeyChain.MakeTpmBackEnd |
| Modifier and Type | Field and Description |
|---|---|
static RsaKeyParams |
DEFAULT_KEY_PARAMS
Deprecated.
Use getDefaultKeyParams().
|
| Constructor and Description |
|---|
KeyChain()
Create a KeyChain with the default PIB and TPM, which are
platform-dependent and can be overridden system-wide or individually by the
user.
|
KeyChain(IdentityManager identityManager)
Create a new security v1 KeyChain with the given IdentityManager and a
NoVerifyPolicyManager.
|
KeyChain(IdentityManager identityManager,
PolicyManager policyManager)
Create a new security v1 KeyChain with the given IdentityManager and
PolicyManager.
|
KeyChain(PibImpl pibImpl,
TpmBackEnd tpmBackEnd)
Create a security v2 KeyChain with explicitly-created PIB and TPM objects.
|
KeyChain(PibImpl pibImpl,
TpmBackEnd tpmBackEnd,
PolicyManager policyManager)
Create a security v2 KeyChain with explicitly-created PIB and TPM objects,
and that still uses the v1 PolicyManager.
|
KeyChain(String pibLocator,
String tpmLocator)
Create a KeyChain to use the PIB and TPM defined by the given locators.
|
KeyChain(String pibLocator,
String tpmLocator,
boolean allowReset)
Create a KeyChain to use the PIB and TPM defined by the given locators.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(PibKey key,
CertificateV2 certificate)
Add a certificate for the key.
|
Name |
createIdentity(Name identityName)
Deprecated.
Use createIdentityAndCertificate which returns the
certificate name instead of the key name.
|
Name |
createIdentity(Name identityName,
KeyParams params)
Deprecated.
Use createIdentityAndCertificate which returns the
certificate name instead of the key name.
|
Name |
createIdentityAndCertificate(Name identityName)
Create a security v1 identity by creating a pair of Key-Signing-Key (KSK)
for this identity and a self-signed certificate of the KSK.
|
Name |
createIdentityAndCertificate(Name identityName,
KeyParams params)
Create a security v1 identity by creating a pair of Key-Signing-Key (KSK)
for this identity and a self-signed certificate of the KSK.
|
PibIdentity |
createIdentityV2(Name identityName)
Create a security V2 identity for identityName.
|
PibIdentity |
createIdentityV2(Name identityName,
KeyParams params)
Create a security V2 identity for identityName.
|
PibKey |
createKey(PibIdentity identity)
Create a key for the identity according to getDefaultKeyParams().
|
PibKey |
createKey(PibIdentity identity,
KeyParams params)
Create a key for the identity according to params.
|
Blob |
createSigningRequest(Name keyName)
Create a public key signing request.
|
void |
deleteCertificate(PibKey key,
Name certificateName)
Delete the certificate with the given name from the given key.
|
void |
deleteIdentity(Name identityName)
Delete the identity from the public and private key storage.
|
void |
deleteIdentity(PibIdentity identity)
Delete the identity.
|
void |
deleteKey(PibIdentity identity,
PibKey key)
Delete the given key of the given identity.
|
SafeBag |
exportSafeBag(CertificateV2 certificate)
Export a certificate and its corresponding private key in a SafeBag, with a
null password which exports an unencrypted PKCS #8 PrivateKeyInfo.
|
SafeBag |
exportSafeBag(CertificateV2 certificate,
ByteBuffer password)
Export a certificate and its corresponding private key in a SafeBag.
|
Name |
generateEcdsaKeyPair(Name identityName)
Generate a pair of ECDSA keys for the specified identity for a
Data-Signing-Key and default keySize 256.
|
Name |
generateEcdsaKeyPair(Name identityName,
boolean isKsk)
Generate a pair of ECDSA keys for the specified identity and default keySize
256.
|
Name |
generateEcdsaKeyPair(Name identityName,
boolean isKsk,
int keySize)
Generate a pair of ECDSA keys for the specified identity.
|
Name |
generateEcdsaKeyPairAsDefault(Name identityName)
Generate a pair of ECDSA keys for the specified identity and set it as
default key for the identity for a Data-Signing-Key and using the default
keySize 256.
|
Name |
generateEcdsaKeyPairAsDefault(Name identityName,
boolean isKsk)
Generate a pair of ECDSA keys for the specified identity and set it as
default key for the identity, using the default keySize 256.
|
Name |
generateEcdsaKeyPairAsDefault(Name identityName,
boolean isKsk,
int keySize)
Generate a pair of ECDSA keys for the specified identity and set it as
default key for the identity.
|
Name |
generateRSAKeyPair(Name identityName)
Generate a pair of RSA keys for the specified identity for a
Data-Signing-Key and default keySize 2048.
|
Name |
generateRSAKeyPair(Name identityName,
boolean isKsk)
Generate a pair of RSA keys for the specified identity and default keySize
2048.
|
Name |
generateRSAKeyPair(Name identityName,
boolean isKsk,
int keySize)
Generate a pair of RSA keys for the specified identity.
|
Name |
generateRSAKeyPairAsDefault(Name identityName)
Generate a pair of RSA keys for the specified identity and set it as
default key for the identity for a Data-Signing-Key and using the default
keySize 2048.
|
Name |
generateRSAKeyPairAsDefault(Name identityName,
boolean isKsk)
Generate a pair of RSA keys for the specified identity and set it as the
default key for the identity, using the default keySize 2048.
|
Name |
generateRSAKeyPairAsDefault(Name identityName,
boolean isKsk,
int keySize)
Generate a pair of RSA keys for the specified identity and set it as the
default key for the identity.
|
IdentityCertificate |
getCertificate(Name certificateName)
Get a certificate with the specified name.
|
Name |
getDefaultCertificateName()
Get the default certificate name of the default identity.
|
Name |
getDefaultIdentity()
Get the default identity.
|
static KeyParams |
getDefaultKeyParams() |
IdentityCertificate |
getIdentityCertificate(Name certificateName)
Deprecated.
Use getCertificate.
|
IdentityManager |
getIdentityManager()
Get the identity manager given to or created by the constructor.
|
boolean |
getIsSecurityV1()
Get the flag set by the constructor if this is a security v1 or v2 KeyChain.
|
Pib |
getPib() |
Tpm |
getTpm() |
void |
importSafeBag(SafeBag safeBag)
Import a certificate and its corresponding private key encapsulated in a
SafeBag, with a null password which imports an unencrypted PKCS #8
PrivateKeyInfo.
|
void |
importSafeBag(SafeBag safeBag,
ByteBuffer password)
Import a certificate and its corresponding private key encapsulated in a
SafeBag.
|
void |
installIdentityCertificate(IdentityCertificate certificate)
Install an identity certificate into the public key identity storage.
|
static void |
registerPibBackend(String scheme,
KeyChain.MakePibImpl makePibImpl)
Add to the PIB factories map where scheme is the key and makePibImpl is the
value.
|
static void |
registerTpmBackend(String scheme,
KeyChain.MakeTpmBackEnd makeTpmBackEnd)
Add to the TPM factories map where scheme is the key and makeTpmBackEnd is
the value.
|
void |
revokeCertificate(Name certificateName)
Revoke a certificate.
|
void |
revokeKey(Name keyName)
Revoke a key.
|
CertificateV2 |
selfSign(PibKey key)
Generate a self-signed certificate for the public key and add it to the
PIB.
|
CertificateV2 |
selfSign(PibKey key,
WireFormat wireFormat)
Generate a self-signed certificate for the public key and add it to the
PIB.
|
void |
setDefaultCertificate(PibKey key,
CertificateV2 certificate)
Set the certificate as the default certificate of the key.
|
void |
setDefaultCertificateForKey(IdentityCertificate certificate)
Set the certificate as the default for its corresponding key.
|
void |
setDefaultIdentity(PibIdentity identity)
Set the identity as the default identity.
|
void |
setDefaultKey(PibIdentity identity,
PibKey key)
Set the key as the default key of identity.
|
void |
setDefaultKeyForIdentity(Name keyName)
Set a key as the default key of an identity.
|
void |
setDefaultKeyForIdentity(Name keyName,
Name identityNameCheck)
Set a key as the default key of an identity.
|
void |
setFace(Face face)
Set the Face which will be used to fetch required certificates.
|
Blob |
sign(ByteBuffer buffer)
Sign the byte buffer using the default key of the default identity.
|
Signature |
sign(ByteBuffer buffer,
Name certificateName)
Sign the byte buffer using a certificate name and return a Signature object.
|
Blob |
sign(ByteBuffer buffer,
SigningInfo params)
Sign the byte buffer according to the supplied signing parameters.
|
void |
sign(Data data)
Wire encode the Data object, sign it with the default key of the default
identity, and set its signature.
|
void |
sign(Data data,
Name certificateName)
Wire encode the Data object, sign it and set its signature.
|
void |
sign(Data data,
Name certificateName,
WireFormat wireFormat)
Wire encode the Data object, sign it and set its signature.
|
void |
sign(Data data,
SigningInfo params)
Wire encode the Data object, sign it according to the supplied signing
parameters, and set its signature.
|
void |
sign(Data data,
SigningInfo params,
WireFormat wireFormat)
Wire encode the Data object, sign it according to the supplied signing
parameters, and set its signature.
|
void |
sign(Data data,
WireFormat wireFormat)
Wire encode the Data object, sign it with the default key of the default
identity, and set its signature.
|
void |
sign(Interest interest)
Sign the Interest with the default key of the default identity.
|
void |
sign(Interest interest,
Name certificateName)
Append a SignatureInfo to the Interest name, sign the name components and
append a final name component with the signature bits.
|
void |
sign(Interest interest,
Name certificateName,
WireFormat wireFormat)
Append a SignatureInfo to the Interest name, sign the name components and
append a final name component with the signature bits.
|
void |
sign(Interest interest,
SigningInfo params)
Sign the Interest according to the supplied signing parameters.
|
void |
sign(Interest interest,
SigningInfo params,
WireFormat wireFormat)
Sign the Interest according to the supplied signing parameters.
|
void |
sign(Interest interest,
WireFormat wireFormat)
Sign the Interest with the default key of the default identity.
|
Signature |
signByIdentity(ByteBuffer buffer,
Name identityName)
Sign the byte buffer using an identity name and return a Signature object.
|
void |
signByIdentity(Data data)
Wire encode the Data object, sign it and set its signature.
|
void |
signByIdentity(Data data,
Name identityName)
Wire encode the Data object, sign it and set its signature.
|
void |
signByIdentity(Data data,
Name identityName,
WireFormat wireFormat)
Wire encode the Data object, sign it and set its signature.
|
static void |
signWithHmacWithSha256(Data data,
Blob key)
Wire encode the data packet, compute an HmacWithSha256 and update the
signature value.
|
static void |
signWithHmacWithSha256(Data data,
Blob key,
WireFormat wireFormat)
Wire encode the data packet, compute an HmacWithSha256 and update the
signature value.
|
static void |
signWithHmacWithSha256(Interest interest,
Blob key,
Name keyName)
Append a SignatureInfo to the Interest name, compute an HmacWithSha256
signature for the name components and append a final name component with
the signature bits.
|
static void |
signWithHmacWithSha256(Interest interest,
Blob key,
Name keyName,
WireFormat wireFormat)
Append a SignatureInfo to the Interest name, compute an HmacWithSha256
signature for the name components and append a final name component with
the signature bits.
|
void |
signWithSha256(Data data)
Wire encode the Data object, digest it and set its SignatureInfo to
a DigestSha256.
|
void |
signWithSha256(Data data,
WireFormat wireFormat)
Wire encode the Data object, digest it and set its SignatureInfo to
a DigestSha256.
|
void |
signWithSha256(Interest interest)
Append a SignatureInfo for DigestSha256 to the Interest name, digest the
name components and append a final name component with the signature bits
(which is the digest).
|
void |
signWithSha256(Interest interest,
WireFormat wireFormat)
Append a SignatureInfo for DigestSha256 to the Interest name, digest the
name components and append a final name component with the signature bits
(which is the digest).
|
void |
verifyData(Data data,
OnVerified onVerified,
OnDataValidationFailed onValidationFailed)
Check the signature on the Data object and call either onVerify.onVerify or
onValidationFailed.onDataValidationFailed.
|
void |
verifyData(Data data,
OnVerified onVerified,
OnDataValidationFailed onValidationFailed,
int stepCount) |
void |
verifyData(Data data,
OnVerified onVerified,
OnVerifyFailed onVerifyFailed)
Deprecated.
Use verifyData with OnDataValidationFailed.
|
static boolean |
verifyDataWithHmacWithSha256(Data data,
Blob key)
Compute a new HmacWithSha256 for the data packet and verify it against the
signature value.
|
static boolean |
verifyDataWithHmacWithSha256(Data data,
Blob key,
WireFormat wireFormat)
Compute a new HmacWithSha256 for the data packet and verify it against the
signature value.
|
void |
verifyInterest(Interest interest,
OnVerifiedInterest onVerified,
OnInterestValidationFailed onValidationFailed)
Check the signature on the signed interest and call either
onVerify.onVerifiedInterest or
onValidationFailed.onInterestValidationFailed.
|
void |
verifyInterest(Interest interest,
OnVerifiedInterest onVerified,
OnInterestValidationFailed onValidationFailed,
int stepCount) |
void |
verifyInterest(Interest interest,
OnVerifiedInterest onVerified,
OnVerifyInterestFailed onVerifyFailed)
Deprecated.
Use verifyInterest with OnInterestValidationFailed.
|
static boolean |
verifyInterestWithHmacWithSha256(Interest interest,
Blob key)
Compute a new HmacWithSha256 for all but the final name component and
verify it against the signature value in the final name component.
|
static boolean |
verifyInterestWithHmacWithSha256(Interest interest,
Blob key,
WireFormat wireFormat)
Compute a new HmacWithSha256 for all but the final name component and
verify it against the signature value in the final name component.
|
public static final RsaKeyParams DEFAULT_KEY_PARAMS
public KeyChain(String pibLocator, String tpmLocator, boolean allowReset) throws KeyChain.Error, PibImpl.Error, SecurityException, IOException
pibLocator - The PIB locator, e.g., "pib-sqlite3:/example/dir".tpmLocator - The TPM locator, e.g., "tpm-memory:".allowReset - If true, the PIB will be reset when the supplied
tpmLocator mismatches the one in the PIB.KeyChain.LocatorMismatchError - if the supplied TPM locator does not
match the locator stored in the PIB.KeyChain.ErrorPibImpl.ErrorSecurityExceptionIOExceptionpublic KeyChain(String pibLocator, String tpmLocator) throws KeyChain.Error, PibImpl.Error, SecurityException, IOException
pibLocator - The PIB locator, e.g., "pib-sqlite3:/example/dir".tpmLocator - The TPM locator, e.g., "tpm-memory:".KeyChain.LocatorMismatchError - if the supplied TPM locator does not
match the locator stored in the PIB.KeyChain.ErrorPibImpl.ErrorSecurityExceptionIOExceptionpublic KeyChain(PibImpl pibImpl, TpmBackEnd tpmBackEnd, PolicyManager policyManager) throws PibImpl.Error
pibImpl - An explicitly-created PIB object of a subclass of PibImpl.tpmBackEnd - An explicitly-created TPM object of a subclass of
TpmBackEnd.policyManager - An object of a subclass of a security v1 PolicyManager.PibImpl.Errorpublic KeyChain(PibImpl pibImpl, TpmBackEnd tpmBackEnd) throws PibImpl.Error
pibImpl - An explicitly-created PIB object of a subclass of PibImpl.tpmBackEnd - An explicitly-created TPM object of a subclass of
TpmBackEnd.PibImpl.Errorpublic KeyChain(IdentityManager identityManager, PolicyManager policyManager)
identityManager - An object of a subclass of IdentityManager.policyManager - An object of a subclass of PolicyManager.public KeyChain(IdentityManager identityManager)
identityManager - An object of a subclass of IdentityManager.public KeyChain()
throws SecurityException,
KeyChain.Error,
PibImpl.Error,
IOException
public final Pib getPib()
public final Tpm getTpm()
public final boolean getIsSecurityV1()
public final PibIdentity createIdentityV2(Name identityName, KeyParams params) throws PibImpl.Error, Pib.Error, Tpm.Error, TpmBackEnd.Error, KeyChain.Error
identityName - The name of the identity.params - The key parameters if a key needs to be generated for the
identity.PibImpl.ErrorPib.ErrorTpm.ErrorTpmBackEnd.ErrorKeyChain.Errorpublic final PibIdentity createIdentityV2(Name identityName) throws PibImpl.Error, Pib.Error, Tpm.Error, TpmBackEnd.Error, KeyChain.Error
identityName - The name of the identity.PibImpl.ErrorPib.ErrorTpm.ErrorTpmBackEnd.ErrorKeyChain.Errorpublic final void deleteIdentity(PibIdentity identity) throws PibImpl.Error, TpmBackEnd.Error
identity - The identity to delete.PibImpl.ErrorTpmBackEnd.Errorpublic final void setDefaultIdentity(PibIdentity identity) throws PibImpl.Error, Pib.Error
identity - The identity to make the default.PibImpl.ErrorPib.Errorpublic final PibKey createKey(PibIdentity identity, KeyParams params) throws Tpm.Error, TpmBackEnd.Error, PibImpl.Error, Pib.Error, KeyChain.Error
identity - A valid PibIdentity object.params - The key parameters if a key needs to be generated for the
identity.Tpm.ErrorTpmBackEnd.ErrorPibImpl.ErrorPib.ErrorKeyChain.Errorpublic final PibKey createKey(PibIdentity identity) throws Tpm.Error, TpmBackEnd.Error, PibImpl.Error, Pib.Error, KeyChain.Error
identity - A valid PibIdentity object.Tpm.ErrorTpmBackEnd.ErrorPibImpl.ErrorPib.ErrorKeyChain.Errorpublic final void deleteKey(PibIdentity identity, PibKey key) throws PibImpl.Error, TpmBackEnd.Error
identity - A valid PibIdentity object.key - The key to delete.IllegalArgumentException - If the key does not belong to the identity.PibImpl.ErrorTpmBackEnd.Errorpublic final void setDefaultKey(PibIdentity identity, PibKey key) throws Pib.Error, PibImpl.Error
identity - A valid PibIdentity object.key - The key to become the default.IllegalArgumentException - If the key does not belong to the identity.Pib.ErrorPibImpl.Errorpublic final void addCertificate(PibKey key, CertificateV2 certificate) throws CertificateV2.Error, PibImpl.Error
key - A valid PibKey object.certificate - The certificate to add. This copies the object.IllegalArgumentException - If the key does not match the certificate.CertificateV2.ErrorPibImpl.Errorpublic final void deleteCertificate(PibKey key, Name certificateName) throws PibImpl.Error
key - A valid PibKey object.certificateName - The name of the certificate to delete.IllegalArgumentException - If certificateName does not follow
certificate naming conventions.PibImpl.Errorpublic final void setDefaultCertificate(PibKey key, CertificateV2 certificate) throws PibImpl.Error, CertificateV2.Error, Pib.Error
key - A valid PibKey object.certificate - The certificate to become the default. This copies the
object.PibImpl.ErrorCertificateV2.ErrorPib.Errorpublic final void sign(Data data, SigningInfo params, WireFormat wireFormat) throws TpmBackEnd.Error, PibImpl.Error, KeyChain.Error
data - The Data object to be signed. This replaces its Signature
object based on the type of key and other info in the SigningInfo params,
and updates the wireEncoding.params - The signing parameters.wireFormat - A WireFormat object used to encode the input.KeyChain.Error - if signing fails.KeyChain.InvalidSigningInfoError - if params is invalid, or if the
identity, key or certificate specified in params does not exist.TpmBackEnd.ErrorPibImpl.Errorpublic final void sign(Data data, SigningInfo params) throws TpmBackEnd.Error, PibImpl.Error, KeyChain.Error
data - The Data object to be signed. This replaces its Signature
object based on the type of key and other info in the SigningInfo params,
and updates the wireEncoding.params - The signing parameters.KeyChain.Error - if signing fails.KeyChain.InvalidSigningInfoError - if params is invalid, or if the
identity, key or certificate specified in params does not exist.TpmBackEnd.ErrorPibImpl.Errorpublic final void sign(Data data, WireFormat wireFormat) throws SecurityException, TpmBackEnd.Error, PibImpl.Error, KeyChain.Error
data - The Data object to be signed. This replaces its Signature
object based on the type of key of the default identity, and updates the
wireEncoding.wireFormat - A WireFormat object used to encode the input.SecurityExceptionTpmBackEnd.ErrorPibImpl.ErrorKeyChain.Errorpublic final void sign(Data data) throws SecurityException, TpmBackEnd.Error, PibImpl.Error, KeyChain.Error
data - The Data object to be signed. This replaces its Signature
object based on the type of key of the default identity, and updates the
wireEncoding.SecurityExceptionTpmBackEnd.ErrorPibImpl.ErrorKeyChain.Errorpublic final void sign(Interest interest, SigningInfo params, WireFormat wireFormat) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.params - The signing parameters.wireFormat - A WireFormat object used to encode the input and encode
the appended components.KeyChain.Error - if signing fails.KeyChain.InvalidSigningInfoError - if params is invalid, or if the
identity, key or certificate specified in params does not exist.PibImpl.ErrorTpmBackEnd.Errorpublic final void sign(Interest interest, SigningInfo params) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.params - The signing parameters.KeyChain.Error - if signing fails.KeyChain.InvalidSigningInfoError - if params is invalid, or if the
identity, key or certificate specified in params does not exist.PibImpl.ErrorTpmBackEnd.Errorpublic final void sign(Interest interest, WireFormat wireFormat) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error, SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.wireFormat - A WireFormat object used to encode the input and encode
the appended components.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.ErrorSecurityExceptionpublic final void sign(Interest interest) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error, SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.ErrorSecurityExceptionpublic final Blob sign(ByteBuffer buffer, SigningInfo params) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
buffer - The byte buffer to be signed.params - The signing parameters. If params refers to an identity, this
selects the default key of the identity. If params refers to a key or
certificate, this selects the corresponding key.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.Errorpublic final Blob sign(ByteBuffer buffer) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
buffer - The byte buffer to be signed.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.Errorpublic final CertificateV2 selfSign(PibKey key, WireFormat wireFormat) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
key - The PibKey with the key name and public key.wireFormat - A WireFormat object used to encode the certificate.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.Errorpublic final CertificateV2 selfSign(PibKey key) throws PibImpl.Error, KeyChain.Error, TpmBackEnd.Error
key - The PibKey with the key name and public key.PibImpl.ErrorKeyChain.ErrorTpmBackEnd.Errorpublic final SafeBag exportSafeBag(CertificateV2 certificate, ByteBuffer password) throws KeyChain.Error
certificate - The certificate to export. This gets the key from the
TPM using certificate.getKeyName().password - The password for encrypting the private key, which should
have characters in the range of 1 to 127. If the password is supplied, use
it to put a PKCS #8 EncryptedPrivateKeyInfo in the SafeBag. If the password
is null, put an unencrypted PKCS #8 PrivateKeyInfo in the SafeBag.KeyChain.Error - certificate.getKeyName() key does not exist, if the
password is null and the TPM does not support exporting an unencrypted
private key, or for other errors exporting the private key.public final SafeBag exportSafeBag(CertificateV2 certificate) throws KeyChain.Error
certificate - The certificate to export. This gets the key from the
TPM using certificate.getKeyName().KeyChain.Error - certificate.getKeyName() key does not exist, if the
TPM does not support exporting an unencrypted private key, or for other
errors exporting the private key.public final void importSafeBag(SafeBag safeBag, ByteBuffer password) throws KeyChain.Error, CertificateV2.Error, TpmBackEnd.Error, PibImpl.Error, Pib.Error
safeBag - The SafeBag containing the certificate and private key. This
copies the values from the SafeBag.password - The password for decrypting the private key, which should
have characters in the range of 1 to 127. If the password is supplied, use
it to decrypt the PKCS #8 EncryptedPrivateKeyInfo. If the password is null,
import an unencrypted PKCS #8 PrivateKeyInfo.KeyChain.Error - if the private key cannot be imported, or if a
public key or private key of the same name already exists, or if a
certificate of the same name already exists.CertificateV2.ErrorTpmBackEnd.ErrorPibImpl.ErrorPib.Errorpublic final void importSafeBag(SafeBag safeBag) throws KeyChain.Error, CertificateV2.Error, TpmBackEnd.Error, PibImpl.Error, Pib.Error
safeBag - The SafeBag containing the certificate and private key. This
copies the values from the SafeBag.KeyChain.Error - if the private key cannot be imported, or if a
public key or private key of the same name already exists, or if a
certificate of the same name already exists.CertificateV2.ErrorTpmBackEnd.ErrorPibImpl.ErrorPib.Errorpublic static void registerPibBackend(String scheme, KeyChain.MakePibImpl makePibImpl)
scheme - The PIB scheme.makePibImpl - An interface with makePibImpl which takes the PIB
location and returns a new PibImpl instance.public static void registerTpmBackend(String scheme, KeyChain.MakeTpmBackEnd makeTpmBackEnd)
scheme - The TPM scheme.makeTpmBackEnd - An interface with makeTpmBackEnd which takes the TPM
location and returns a new TpmBackEnd instance.public final Name createIdentityAndCertificate(Name identityName, KeyParams params) throws SecurityException
identityName - The name of the identity.params - The key parameters if a key needs to be generated for the
identity.SecurityException - if the identity has already been created.public final Name createIdentityAndCertificate(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityException - if the identity has already been created.public final Name createIdentity(Name identityName, KeyParams params) throws SecurityException
identityName - The name of the identity.params - The key parameters if a key needs to be generated for the
identity.SecurityException - if the identity has already been created.public final Name createIdentity(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityException - if the identity has already been created.public final void deleteIdentity(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityExceptionpublic final Name getDefaultIdentity() throws SecurityException
SecurityException - if the default identity is not set.public final Name getDefaultCertificateName() throws SecurityException
SecurityException - if the default identity is not set or the default
key name for the identity is not set or the default certificate name for
the key name is not set.public final Name generateRSAKeyPair(Name identityName, boolean isKsk, int keySize) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).keySize - The size of the key.SecurityExceptionpublic final Name generateRSAKeyPair(Name identityName, boolean isKsk) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).SecurityExceptionpublic final Name generateRSAKeyPair(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityExceptionpublic final Name generateEcdsaKeyPair(Name identityName, boolean isKsk, int keySize) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).keySize - The size of the key.SecurityExceptionpublic final Name generateEcdsaKeyPair(Name identityName, boolean isKsk) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).SecurityExceptionpublic final Name generateEcdsaKeyPair(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityExceptionpublic final void setDefaultKeyForIdentity(Name keyName, Name identityNameCheck) throws SecurityException
keyName - The name of the key.identityNameCheck - The identity name to check that the keyName
contains the same identity name. If an empty name, it is ignored.SecurityExceptionpublic final void setDefaultKeyForIdentity(Name keyName) throws SecurityException
keyName - The name of the key.SecurityExceptionpublic final Name generateRSAKeyPairAsDefault(Name identityName, boolean isKsk, int keySize) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).keySize - The size of the key.SecurityExceptionpublic final Name generateRSAKeyPairAsDefault(Name identityName, boolean isKsk) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).SecurityExceptionpublic final Name generateRSAKeyPairAsDefault(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityExceptionpublic final Name generateEcdsaKeyPairAsDefault(Name identityName, boolean isKsk, int keySize) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).keySize - The size of the key.SecurityExceptionpublic final Name generateEcdsaKeyPairAsDefault(Name identityName, boolean isKsk) throws SecurityException
identityName - The name of the identity.isKsk - true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).SecurityExceptionpublic final Name generateEcdsaKeyPairAsDefault(Name identityName) throws SecurityException
identityName - The name of the identity.SecurityExceptionpublic final Blob createSigningRequest(Name keyName) throws SecurityException
keyName - The name of the key.SecurityException - if the keyName is not found.public final void installIdentityCertificate(IdentityCertificate certificate) throws SecurityException
certificate - The certificate to to added.SecurityExceptionpublic final void setDefaultCertificateForKey(IdentityCertificate certificate) throws SecurityException
certificate - The certificate.SecurityExceptionpublic final IdentityCertificate getCertificate(Name certificateName) throws SecurityException, DerDecodingException
certificateName - The name of the requested certificate.SecurityExceptionDerDecodingExceptionpublic final IdentityCertificate getIdentityCertificate(Name certificateName) throws SecurityException, DerDecodingException
public final void revokeKey(Name keyName)
keyName - The name of the key that will be revoked.public final void revokeCertificate(Name certificateName)
certificateName - The name of the certificate that will be revoked.public final IdentityManager getIdentityManager()
public final void sign(Data data, Name certificateName, WireFormat wireFormat) throws SecurityException
data - The Data object to be signed. This updates its signature and
key locator field and wireEncoding.certificateName - The certificate name of the key to use for signing.wireFormat - A WireFormat object used to encode the input.SecurityExceptionpublic final void sign(Data data, Name certificateName) throws SecurityException
data - The Data object to be signed. This updates its signature and
key locator field and wireEncoding.certificateName - The certificate name of the key to use for signing.SecurityExceptionpublic final void sign(Interest interest, Name certificateName, WireFormat wireFormat) throws SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.certificateName - The certificate name of the key to use for signing.wireFormat - A WireFormat object used to encode the input.SecurityExceptionpublic final void sign(Interest interest, Name certificateName) throws SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.certificateName - The certificate name of the key to use for signing.SecurityExceptionpublic Signature sign(ByteBuffer buffer, Name certificateName) throws SecurityException
buffer - The byte array to be signed.certificateName - The certificate name used to get the signing key and which will be put into KeyLocator.SecurityExceptionpublic final void signByIdentity(Data data, Name identityName, WireFormat wireFormat) throws SecurityException
data - The Data object to be signed. This updates its signature and
key locator field and wireEncoding.identityName - The identity name for the key to use for signing.
If empty, infer the signing identity from the data packet name.wireFormat - A WireFormat object used to encode the input. If omitted, use WireFormat getDefaultWireFormat().SecurityExceptionpublic final void signByIdentity(Data data, Name identityName) throws SecurityException
data - The Data object to be signed. This updates its signature and
key locator field and wireEncoding.
Use the default WireFormat.getDefaultWireFormat().identityName - The identity name for the key to use for signing.
If empty, infer the signing identity from the data packet name.SecurityExceptionpublic final void signByIdentity(Data data) throws SecurityException
data - The Data object to be signed. This updates its signature and
key locator field and wireEncoding.
Infer the signing identity from the data packet name.
Use the default WireFormat.getDefaultWireFormat().SecurityExceptionpublic Signature signByIdentity(ByteBuffer buffer, Name identityName) throws SecurityException
buffer - The byte array to be signed.identityName - The identity name.SecurityExceptionpublic final void signWithSha256(Data data, WireFormat wireFormat) throws SecurityException
data - The Data object to be signed. This updates its signature and
wireEncoding.wireFormat - A WireFormat object used to encode the input.SecurityExceptionpublic final void signWithSha256(Data data) throws SecurityException
data - The Data object to be signed. This updates its signature and
wireEncoding.SecurityExceptionpublic final void signWithSha256(Interest interest, WireFormat wireFormat) throws SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.wireFormat - A WireFormat object used to encode the input.SecurityExceptionpublic final void signWithSha256(Interest interest) throws SecurityException
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.SecurityExceptionpublic final void verifyData(Data data, OnVerified onVerified, OnDataValidationFailed onValidationFailed, int stepCount) throws SecurityException
SecurityExceptionpublic final void verifyData(Data data, OnVerified onVerified, OnDataValidationFailed onValidationFailed) throws SecurityException
data - The Data object with the signature to check. It is an error if
data does not have a wireEncoding.
To set the wireEncoding, you can call data.wireDecode.onVerified - If the signature is verified, this calls
onVerified.onVerified(data).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onValidationFailed - If the signature check fails, this calls
onValidationFailed.onDataValidationFailed(data, reason).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.SecurityExceptionpublic final void verifyData(Data data, OnVerified onVerified, OnVerifyFailed onVerifyFailed) throws SecurityException
data - The Data object with the signature to check. It is an error if
data does not have a wireEncoding.
To set the wireEncoding, you can call data.wireDecode.onVerified - If the signature is verified, this calls
onVerified.onVerified(data).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onVerifyFailed - If the signature check fails, this calls
onVerifyFailed.onVerifyFailed(data).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.SecurityExceptionpublic final void verifyInterest(Interest interest, OnVerifiedInterest onVerified, OnInterestValidationFailed onValidationFailed, int stepCount) throws SecurityException
SecurityExceptionpublic final void verifyInterest(Interest interest, OnVerifiedInterest onVerified, OnInterestValidationFailed onValidationFailed) throws SecurityException
interest - The interest with the signature to check.onVerified - If the signature is verified, this calls
onVerified.onVerifiedInterest(interest).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onValidationFailed - If the signature check fails, this calls
onValidationFailed.onInterestValidationFailed(interest, reason).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.SecurityExceptionpublic final void verifyInterest(Interest interest, OnVerifiedInterest onVerified, OnVerifyInterestFailed onVerifyFailed) throws SecurityException
interest - The interest with the signature to check.onVerified - If the signature is verified, this calls
onVerified.onVerifiedInterest(interest).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onVerifyFailed - If the signature check fails, this calls
onVerifyFailed.onVerifyInterestFailed(interest).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.SecurityExceptionpublic final void setFace(Face face)
face - The Face object.public static void signWithHmacWithSha256(Data data, Blob key, WireFormat wireFormat)
data - The Data object to be signed. This updates its signature.key - The key for the HmacWithSha256.wireFormat - A WireFormat object used to encode the data packet.public static void signWithHmacWithSha256(Data data, Blob key)
data - The Data object to be signed. This updates its signature.key - The key for the HmacWithSha256.public static void signWithHmacWithSha256(Interest interest, Blob key, Name keyName, WireFormat wireFormat)
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.key - The key for the HmacWithSha256.keyName - The name of the key for the KeyLocator in the SignatureInfo.wireFormat - A WireFormat object used to encode the input.public static void signWithHmacWithSha256(Interest interest, Blob key, Name keyName)
interest - The Interest object to be signed. This appends name
components of SignatureInfo and the signature bits.key - The key for the HmacWithSha256.keyName - The name of the key for the KeyLocator in the SignatureInfo.public static boolean verifyDataWithHmacWithSha256(Data data, Blob key, WireFormat wireFormat)
data - The Data packet to verify.key - The key for the HmacWithSha256.wireFormat - A WireFormat object used to encode the data packet.public static boolean verifyDataWithHmacWithSha256(Data data, Blob key)
data - The Data packet to verify.key - The key for the HmacWithSha256.public static boolean verifyInterestWithHmacWithSha256(Interest interest, Blob key, WireFormat wireFormat)
interest - The Interest object to verify.key - The key for the HmacWithSha256.wireFormat - A WireFormat object used to encode the input.public static boolean verifyInterestWithHmacWithSha256(Interest interest, Blob key)
interest - The Interest object to verify.key - The key for the HmacWithSha256.public static KeyParams getDefaultKeyParams()
Copyright © 2019. All rights reserved.