Methods
CalculateAddr(pubKeyPEMnon-null) → {Buffer}
根据公钥信息计算其bitcoin地址
Parameters:
Name | Type | Description |
---|---|---|
pubKeyPEM |
string | 符合PKCS#8标准的pem格式公钥信息,或符合X.509标准的公钥证书信息,目前只支持EC-secp256k1曲线 |
Returns:
bitcoin地址的Buffer数据
- Type
- Buffer
CreateCertificate(certFields, creatoropt, cbopt) → {string}
生成符合X.509标准的证书信息
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
certFields |
Object | 证书的具体信息,
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
creator |
string |
<optional> |
证书生成者,支持使用jsrsasign或gm(即国密),默认使用jsrsasign | ||||||||||||||||||||||||||||||||||||||||||||
cb |
gmCertificateCallback |
<optional> |
回调函数,gm证书生成实现是异步的,所以当creator为gm时,需要提供该参数 |
Returns:
certPEM pem格式的证书信息,当creator为jsrsasign时,将返回该信息
- Type
- string
CreateCSR(params) → {string}
生成PEM格式的证书签名请求(Certificate Signing Request, CSR)信息
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | 生成csr所需参数
Properties
|
Returns:
PEM格式的csr信息
- Type
- string
CreateKeypair(algopt, keyLenOrCurveopt) → {Object}
创建非对称密钥对,支持RSA与EC密钥对生成
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
alg |
string |
<optional> |
EC | 密钥对生成算法,RSA或EC,默认使用EC |
keyLenOrCurve |
string | number |
<optional> |
secp256k1 | 指定密钥长度(针对RSA)或曲线名(针对EC), 默认使用EC secp256k1曲线 |
Returns:
keypair 含有jsrsasign提供的prvKeyObj与pubKeyObj对象
- Type
- Object
CreateSelfSignedCertificate(certFields) → {string}
生成符合X.509标准的自签名证书信息
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
certFields |
Object | 证书具体信息
Properties
|
Returns:
certPEM pem格式的自签名证书信息
- Type
- string
GetCSRInfoFromPEM(csrPEM) → {Object}
从PEM格式的csr中获取csr信息
Parameters:
Name | Type | Description |
---|---|---|
csrPEM |
string | PEM格式的csr信息 |
Returns:
csrInfo 解析后的csr信息(JSON)
csrInfo.pubkey.obj - 证书拥有者公钥对象(jsrsasign提供的RSAKey, KJUR.crypto.{ECDSA,DSA})
csrInfo.pubkey.hex - 证书拥有者公钥的hex格式
csrInfo.subject.name - 证书拥有者唯一标识名
csrInfo.subject.hex - 证书拥有者唯一标识名的hex格式
- Type
- Object
GetHashVal(getHashParamsnon-null) → {Buffer}
根据指定的密码学哈希算法为给定数据计算哈希值
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getHashParams |
Object | 计算哈希值所需参数
Properties
|
Returns:
digest 结果哈希值,若使用sm3将返回undefined
- Type
- Buffer
GetKeyPEM(keyObj, passWordopt) → {string}
获得PEM格式的私钥或公钥信息
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyObj |
Object | prvKeyObj或pubKeyObj | |
passWord |
string |
<optional> |
私钥保护密码,当需要生成加密私钥信息时需提供该参数, 目前是由jsrsasign使用PBKDF2_HmacSHA1_3DES算法对私钥进行加密 |
Returns:
keyPEM 符合PKCS#8标准的密钥信息
- Type
- string
ImportCertificate(certPEM) → {Object}
导入已有的公钥证书信息
Parameters:
Name | Type | Description |
---|---|---|
certPEM |
string | 符合X.509标准的公钥证书信息 |
Returns:
x509 jsrsasign提供的X509对象实例
- Type
- Object
ImportKey(keyPEM, passWordopt) → {Object}
导入已有非对称密钥
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyPEM |
string | 使用符合PKCS#8标准的pem格式私钥信息获取私钥对象,支持导入使用PBKDF2_HmacSHA1_3DES加密的pem格式私钥信息 使用符合PKCS#8标准的pem格式公钥信息或符合X.509标准的pem格式证书信息获取公钥对象 | |
passWord |
string |
<optional> |
私钥保护密码, 当导入已加密私钥时,需要提供该参数 |
Returns:
keyObj密钥对象,prvkeyObj或pubKeyObj
- Type
- Object
Sign(signParams) → {Buffer}
根据指定私钥和签名算法,对给定数据进行签名
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
signParams |
Object | 签名所需参数
Properties
|
Returns:
signature 签名结果值,当使用非国密签名时,会返回该结果
- Type
- Buffer
VerifyCertificateSignature(certPEM, pubKey) → {boolean}
验证证书签名信息
Parameters:
Name | Type | Description |
---|---|---|
certPEM |
string | 符合X509标准的公钥证书信息 |
pubKey |
Object | 证书签发者的公钥对象 |
Returns:
证书签名验证结果
- Type
- boolean
VerifySign(verifySignatureParams) → {boolean}
验证签名
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
verifySignatureParams |
Object | 验证签名所需参数
Properties
|
Returns:
isValid 签名真实性鉴定结果
- Type
- boolean
Type Definitions
gmCertificateCallback(certPEM)
Parameters:
Name | Type | Description |
---|---|---|
certPEM |
string | pem格式证书 |
gmGetHashCallback(sm3HashVal)
Parameters:
Name | Type | Description |
---|---|---|
sm3HashVal |
string | hex格式的国密算法哈希值 |
gmSignCallback(signature)
Parameters:
Name | Type | Description |
---|---|---|
signature |
string | hex格式签名信息 |
websocketCallback(eventMessage)
Parameters:
Name | Type | Description |
---|---|---|
eventMessage |
Object |