public class CryptoSuite
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
int |
cryptoTypeConfig |
Hash |
hashImpl |
Signature |
signatureImpl |
| 构造器和说明 |
|---|
CryptoSuite(int cryptoTypeConfig)
Init the common crypto implementation according to the crypto type
|
CryptoSuite(int cryptoTypeConfig,
ConfigOption configOption)
init CryptoSuite
|
CryptoSuite(int cryptoTypeConfig,
CryptoKeyPair cryptoKeyPair) |
CryptoSuite(int cryptoTypeConfig,
java.lang.String hexedPrivateKey) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
destroy() |
CryptoKeyPair |
generateRandomKeyPair()
Create key pair
|
ConfigOption |
getConfig()
Get configuration
|
CryptoKeyPair |
getCryptoKeyPair()
Get the key pair of the CryptoSuite
|
int |
getCryptoTypeConfig() |
Hash |
getHashImpl()
Get hash function, which is relate to the configured CryptoType
|
CryptoKeyPair |
getKeyPairFactory()
Get key pair factory
|
Signature |
getSignatureImpl() |
byte[] |
hash(byte[] inputBytes)
Call hash function
|
java.lang.String |
hash(java.lang.String inputData)
Call hash function
|
void |
loadAccount(java.lang.String accountFileFormat,
java.lang.String accountFilePath,
java.lang.String password)
Load account from file
|
CryptoKeyPair |
loadKeyPair(java.security.KeyPair keyPair)
Create CryptoKeyPair type key pair from KeyPair type key pair
|
CryptoKeyPair |
loadKeyPair(java.lang.String hexedPrivateKey)
Create key pair from a private key string
|
void |
setConfig(ConfigOption config)
Set config
|
void |
setCryptoKeyPair(CryptoKeyPair cryptoKeyPair)
Set the key pair in CryptoSuite
|
SignatureResult |
sign(byte[] message,
CryptoKeyPair keyPair)
Do signature
|
java.lang.String |
sign(KeyTool keyTool,
java.lang.String message)
Do signature, used in AMOP private topic verification procedure
|
SignatureResult |
sign(java.lang.String message,
CryptoKeyPair keyPair)
Do signature
|
boolean |
verify(KeyTool keyTool,
byte[] message,
byte[] signature)
Verify signature, used in AMOP private topic verification procedure
|
boolean |
verify(KeyTool keyTool,
java.lang.String message,
java.lang.String signature)
Verify signature, used in AMOP private topic verification procedure
|
boolean |
verify(java.lang.String publicKey,
byte[] message,
byte[] signature)
Verify signature
|
boolean |
verify(java.lang.String publicKey,
java.lang.String message,
java.lang.String signature)
Verify signature
|
public final int cryptoTypeConfig
public final Signature signatureImpl
public final Hash hashImpl
public CryptoSuite(int cryptoTypeConfig,
CryptoKeyPair cryptoKeyPair)
public CryptoSuite(int cryptoTypeConfig,
java.lang.String hexedPrivateKey)
public CryptoSuite(int cryptoTypeConfig,
ConfigOption configOption)
cryptoTypeConfig - the crypto type, e.g. ECDSA_TYPE or SM_TYPEconfigOption - the configuration of account.public CryptoSuite(int cryptoTypeConfig)
cryptoTypeConfig - the crypto type config numberpublic void loadAccount(java.lang.String accountFileFormat,
java.lang.String accountFilePath,
java.lang.String password)
accountFileFormat - file format, e.g. p21, pemaccountFilePath - file pathpassword - password of the key filepublic void setConfig(ConfigOption config)
config - ConfigOption type configurationpublic int getCryptoTypeConfig()
public Signature getSignatureImpl()
public Hash getHashImpl()
public java.lang.String hash(java.lang.String inputData)
inputData - string type input datapublic byte[] hash(byte[] inputBytes)
inputBytes - byte array type input datapublic SignatureResult sign(byte[] message, CryptoKeyPair keyPair)
message - byte array type input string, must be a digestkeyPair - key pair used to do signaturepublic SignatureResult sign(java.lang.String message, CryptoKeyPair keyPair)
message - string type input message, must be a digestkeyPair - key pair used to do signaturepublic java.lang.String sign(KeyTool keyTool, java.lang.String message)
keyTool - the keymessage - the string type input message, must be a digestpublic boolean verify(KeyTool keyTool, java.lang.String message, java.lang.String signature)
keyTool - the keymessage - the string type input message, must be a digestsignature - the string type signaturepublic boolean verify(KeyTool keyTool, byte[] message, byte[] signature)
keyTool - the keymessage - the byte array type input message, must be a digestsignature - the byte array type signaturepublic boolean verify(java.lang.String publicKey,
java.lang.String message,
java.lang.String signature)
publicKey - the string type public keymessage - the string type input message, must be a digestsignature - the string type signaturepublic boolean verify(java.lang.String publicKey,
byte[] message,
byte[] signature)
publicKey - the string type public keymessage - the byte array type input message, must be a digestsignature - the byte array type signaturepublic CryptoKeyPair generateRandomKeyPair()
public CryptoKeyPair loadKeyPair(java.security.KeyPair keyPair)
keyPair - key pairpublic CryptoKeyPair loadKeyPair(java.lang.String hexedPrivateKey)
hexedPrivateKey - a hex string of private keypublic void setCryptoKeyPair(CryptoKeyPair cryptoKeyPair)
cryptoKeyPair - set the CryptoKeyPair objectpublic CryptoKeyPair getCryptoKeyPair()
public ConfigOption getConfig()
public CryptoKeyPair getKeyPairFactory()
public void destroy()