Class PowerAuthClientActivation
java.lang.Object
io.getlime.security.powerauth.crypto.client.activation.PowerAuthClientActivation
Class implementing a cryptography used on the client side in order
to complete the PowerAuth Client activation.
- Author:
- Petr Dvorak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeActivationFingerprint(PublicKey devicePublicKey, PublicKey serverPublicKey, String activationId) Compute a fingerprint for the version 3 activation.computeActivationFingerprint(PublicKey devicePublicKey, PublicKey serverPublicKey, String activationId, ActivationVersion activationVersion) Compute a fingerprint for the activation.byte[]Generate a new activation nonce.Generate a device related activation key pair.getStatusFromEncryptedBlob(byte[] cStatusBlob, byte[] challenge, byte[] nonce, SecretKey transportKey) Returns an activation status from the encrypted activation blob as described in PowerAuth Specification.booleanverifyActivationCodeSignature(String activationCode, byte[] signature, PublicKey masterPublicKey) Verify the signature of activation code using Master Public Key.booleanverifyHashForHashBasedCounter(byte[] receivedCtrDataHash, byte[] expectedCtrData, SecretKey transportKey) Verify whether client's value of hash based counter is equal to the value received from the server.booleanverifyServerDataSignature(String activationId, byte[] C_serverPublicKey, byte[] signature, PublicKey masterPublicKey) Verify signature of the encrypted activation ID and server public key using a Master Public Key.
-
Constructor Details
-
PowerAuthClientActivation
public PowerAuthClientActivation()
-
-
Method Details
-
verifyActivationCodeSignature
public boolean verifyActivationCodeSignature(String activationCode, byte[] signature, PublicKey masterPublicKey) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Verify the signature of activation code using Master Public Key.- Parameters:
activationCode- Activation code.signature- Activation data signature.masterPublicKey- Master Public Key.- Returns:
- Returns "true" if the signature matches activation data, "false" otherwise.
- Throws:
InvalidKeyException- If provided master public key is invalid.GenericCryptoException- In case signature computation fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
generateDeviceKeyPair
Generate a device related activation key pair.- Returns:
- A new device key pair.
- Throws:
CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
generateActivationNonce
Generate a new activation nonce.- Returns:
- A new activation nonce.
- Throws:
CryptoProviderException- In case key cryptography provider is incorrectly initialized.
-
verifyServerDataSignature
public boolean verifyServerDataSignature(String activationId, byte[] C_serverPublicKey, byte[] signature, PublicKey masterPublicKey) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Verify signature of the encrypted activation ID and server public key using a Master Public Key.- Parameters:
activationId- Activation IDC_serverPublicKey- Encrypted server public key.signature- Encrypted server public key signature.masterPublicKey- Master Public Key.- Returns:
- Returns "true" if signature matches encrypted data, "false" otherwise.
- Throws:
InvalidKeyException- If provided master public key is invalid.GenericCryptoException- In case signature computation fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
computeActivationFingerprint
public String computeActivationFingerprint(PublicKey devicePublicKey, PublicKey serverPublicKey, String activationId) throws GenericCryptoException, CryptoProviderException Compute a fingerprint for the version 3 activation. The fingerprint can be used for visual validation of exchanged device public key.PowerAuth protocol versions:
- 3.0
- 3.1
- 3.2
- Parameters:
devicePublicKey- Device public key.serverPublicKey- Server public key.activationId- Activation ID.- Returns:
- Fingerprint of the public key.
- Throws:
CryptoProviderException- In case cryptography provider is incorrectly initialized.GenericCryptoException- In case fingerprint could not be calculated.
-
computeActivationFingerprint
public String computeActivationFingerprint(PublicKey devicePublicKey, PublicKey serverPublicKey, String activationId, ActivationVersion activationVersion) throws GenericCryptoException, CryptoProviderException Compute a fingerprint for the activation. The fingerprint can be used for visual validation of exchanged public keys.- Parameters:
devicePublicKey- Device public key.serverPublicKey- Server public key.activationId- Activation ID.activationVersion- Activation version.- Returns:
- Fingerprint of the public keys.
- Throws:
CryptoProviderException- In case cryptography provider is incorrectly initialized.GenericCryptoException- In case fingerprint could not be calculated.
-
getStatusFromEncryptedBlob
public ActivationStatusBlobInfo getStatusFromEncryptedBlob(byte[] cStatusBlob, byte[] challenge, byte[] nonce, SecretKey transportKey) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Returns an activation status from the encrypted activation blob as described in PowerAuth Specification.- Parameters:
cStatusBlob- Encrypted activation status blob.challenge- Challenge for activation status blob encryption. If non-null, then alsononceparameter must be provided.nonce- Nonce for activation status blob encryption. If non-null, then alsochallengeparameter must be provided.transportKey- A key used to protect the transport.- Returns:
- Status information from the status blob.
- Throws:
InvalidKeyException- When invalid key is provided.GenericCryptoException- In case decryption fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
verifyHashForHashBasedCounter
public boolean verifyHashForHashBasedCounter(byte[] receivedCtrDataHash, byte[] expectedCtrData, SecretKey transportKey) throws CryptoProviderException, InvalidKeyException, GenericCryptoException Verify whether client's value of hash based counter is equal to the value received from the server. The value received from the server is already hashed, so the function has to calculate hash from the client's counter and then compare both values.- Parameters:
receivedCtrDataHash- Value received from the server, containing hash, calculated from hash based counter.expectedCtrData- Expected hash based counter.transportKey- Transport key.- Returns:
truein case that received hash equals to hash calculated from counter data.- Throws:
InvalidKeyException- When invalid key is provided.GenericCryptoException- In case key derivation fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-