public class VirgilKeyPair extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
VirgilKeyPair.Type
Type of the keypair.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
swigCMemOwn |
| Modifier | Constructor and Description |
|---|---|
|
VirgilKeyPair(byte[] publicKey,
byte[] privateKey)
Create a new instance of
VirgilKeyPair |
protected |
VirgilKeyPair(long cPtr,
boolean cMemoryOwn) |
|
VirgilKeyPair(VirgilKeyPair other)
Create a new instance of
VirgilKeyPair |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkPrivateKeyPassword(byte[] key,
byte[] pwd)
Check if given private key and it's password matches.
|
void |
close() |
static byte[] |
decryptPrivateKey(byte[] privateKey,
byte[] privateKeyPassword)
Decrypt the given private key and return result.
|
void |
delete() |
static byte[] |
encryptPrivateKey(byte[] privateKey,
byte[] privateKeyPassword)
Encrypt the given private key and return result.
|
static byte[] |
extractPublicKey(byte[] privateKey,
byte[] privateKeyPassword)
Extract public key from the private key.
|
protected void |
finalize() |
static VirgilKeyPair |
generate(VirgilKeyPair.Type type)
Generate new key pair given type.
|
static VirgilKeyPair |
generate(VirgilKeyPair.Type type,
byte[] pwd)
Generate new key pair given type.
|
static VirgilKeyPair |
generateFrom(VirgilKeyPair donorKeyPair)
Generate new key pair of the same type based on the donor key pair.
|
static VirgilKeyPair |
generateFrom(VirgilKeyPair donorKeyPair,
byte[] donorPrivateKeyPassword)
Generate new key pair of the same type based on the donor key pair.
|
static VirgilKeyPair |
generateFrom(VirgilKeyPair donorKeyPair,
byte[] donorPrivateKeyPassword,
byte[] newKeyPairPassword)
Generate new key pair of the same type based on the donor key pair.
|
static VirgilKeyPair |
generateRecommended()
Generate new key pair with recommended most safe type.
|
static VirgilKeyPair |
generateRecommended(byte[] pwd)
Generate new key pair with recommended most safe type.
|
protected static long |
getCPtr(VirgilKeyPair obj) |
static boolean |
isKeyPairMatch(byte[] publicKey,
byte[] privateKey)
Check if a public-private pair of keys matches.
|
static boolean |
isKeyPairMatch(byte[] publicKey,
byte[] privateKey,
byte[] privateKeyPassword)
Check if a public-private pair of keys matches.
|
static boolean |
isPrivateKeyEncrypted(byte[] privateKey)
Check if given private key is encrypted.
|
byte[] |
privateKey()
Provide access to the private key.
|
static byte[] |
privateKeyToDER(byte[] privateKey)
Convert given private key to the DER format.
|
static byte[] |
privateKeyToDER(byte[] privateKey,
byte[] privateKeyPassword)
Convert given private key to the DER format.
|
static byte[] |
privateKeyToPEM(byte[] privateKey)
Convert given private key to the PEM format.
|
static byte[] |
privateKeyToPEM(byte[] privateKey,
byte[] privateKeyPassword)
Convert given private key to the PEM format.
|
byte[] |
publicKey()
Provide access to the public key.
|
static byte[] |
publicKeyToDER(byte[] publicKey)
Convert given public key to the DER format.
|
static byte[] |
publicKeyToPEM(byte[] publicKey)
Convert given public key to the PEM format.
|
static byte[] |
resetPrivateKeyPassword(byte[] privateKey,
byte[] oldPassword,
byte[] newPassword)
Reset password for the given private key.
|
protected VirgilKeyPair(long cPtr,
boolean cMemoryOwn)
public VirgilKeyPair(byte[] publicKey,
byte[] privateKey)
VirgilKeyPairpublicKey - privateKey - public VirgilKeyPair(VirgilKeyPair other)
VirgilKeyPairother - the source key pair.protected static long getCPtr(VirgilKeyPair obj)
public void delete()
public void close()
close in interface AutoCloseablepublic static VirgilKeyPair generate(VirgilKeyPair.Type type, byte[] pwd)
type - the private key type to be generated.pwd - the private key password.public static VirgilKeyPair generate(VirgilKeyPair.Type type)
type - the private key type to be generated.public static VirgilKeyPair generateRecommended(byte[] pwd)
pwd - Private key password.public static VirgilKeyPair generateRecommended()
public static VirgilKeyPair generateFrom(VirgilKeyPair donorKeyPair, byte[] donorPrivateKeyPassword, byte[] newKeyPairPassword)
donorKeyPair - Public key or private key is used to determine the new key
pair type.donorPrivateKeyPassword - Donor private key password, optional if public key is defined.newKeyPairPassword - Private key password of the new key pair.public static VirgilKeyPair generateFrom(VirgilKeyPair donorKeyPair, byte[] donorPrivateKeyPassword)
donorKeyPair - Public key or private key is used to determine the new key
pair type.donorPrivateKeyPassword - Donor private key password, optional if public key is defined.public static VirgilKeyPair generateFrom(VirgilKeyPair donorKeyPair)
donorKeyPair - Public key or private key is used to determine the new key
pair type.public static boolean isKeyPairMatch(byte[] publicKey,
byte[] privateKey,
byte[] privateKeyPassword)
publicKey - Public key in DER or PEM format.privateKey - Private key in DER or PEM format.privateKeyPassword - Private key password if exists.true if keys matche.public static boolean isKeyPairMatch(byte[] publicKey,
byte[] privateKey)
publicKey - Public key in DER or PEM format.privateKey - Private key in DER or PEM format.true if keys matche.public static boolean checkPrivateKeyPassword(byte[] key,
byte[] pwd)
key - Private key in DER or PEM format.pwd - Private key password.true if private key and it's password matches.public static boolean isPrivateKeyEncrypted(byte[] privateKey)
privateKey - Private key in DER or PEM format.true - if private key is encrypted.public static byte[] resetPrivateKeyPassword(byte[] privateKey,
byte[] oldPassword,
byte[] newPassword)
Reset password for the given private key.
Re-encrypt given Private Key with a new password.
privateKey - Private key that is encrypted with old password.oldPassword - Current Private Key password.newPassword - New Private Key password.public static byte[] encryptPrivateKey(byte[] privateKey,
byte[] privateKeyPassword)
privateKey - Private key in the plain text.privateKeyPassword - New Private Key password.public static byte[] decryptPrivateKey(byte[] privateKey,
byte[] privateKeyPassword)
privateKey - Encrypted Private Key.privateKeyPassword - Current Private Key password.public static byte[] extractPublicKey(byte[] privateKey,
byte[] privateKeyPassword)
privateKey - Private key.privateKeyPassword - Private key password.public static byte[] publicKeyToPEM(byte[] publicKey)
publicKey - Public key to be converted.public static byte[] publicKeyToDER(byte[] publicKey)
publicKey - Public key to be converted.public static byte[] privateKeyToPEM(byte[] privateKey,
byte[] privateKeyPassword)
privateKey - Private key to be converted.privateKeyPassword - Private key password.public static byte[] privateKeyToPEM(byte[] privateKey)
privateKey - Private key to be converted.public static byte[] privateKeyToDER(byte[] privateKey,
byte[] privateKeyPassword)
privateKey - Private key to be converted.privateKeyPassword - Private key password.public static byte[] privateKeyToDER(byte[] privateKey)
privateKey - Private key to be converted.public byte[] publicKey()
public byte[] privateKey()
Copyright © 2016. All rights reserved.