Class Index | File Index

Classes


Class KJUR.crypto.ECDSA

class for EC key generation, ECDSA signing and verifcation
Defined in: ecdsa-modified-1.0.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
class for EC key generation, ECDSA signing and verifcation

CAUTION: Most of the case, you don't need to use this class except for generating an EC key pair.

Method Summary
Method Attributes Method Name and Description
<static>  
KJUR.crypto.ECDSA.asn1SigToConcatSig(asn1Hex)
convert hexadecimal ASN.1 encoded signature to concatinated signature
<static>  
KJUR.crypto.ECDSA.biRSSigToASN1Sig(biR, biS)
convert R and S BigInteger object of signature to ASN.1 encoded signature
<static>  
KJUR.crypto.ECDSA.concatSigToASN1Sig(concatSig)
convert hexadecimal concatinated signature to ASN.1 encoded signature
 
generate a EC key pair
<static>  
KJUR.crypto.ECDSA.getName(s)
static method to get normalized EC curve name from curve name or hexadecimal OID value This static method returns normalized EC curve name which is supported in jsrsasign from curve name or hexadecimal OID value.
 
get X and Y hexadecimal string value of public key
 
get NIST curve short name such as "P-256" or "P-384"
<static>  
KJUR.crypto.ECDSA.hexRSSigToASN1Sig(hR, hS)
convert hexadecimal R and S value of signature to ASN.1 encoded signature
<static>  
KJUR.crypto.ECDSA.parseSigHex(sigHex)
parse ASN.1 DER encoded ECDSA signature
<static>  
KJUR.crypto.ECDSA.parseSigHexInHexRS(sigHex)
parse ASN.1 DER encoded ECDSA signature
 
readCertPubKeyHex(h, nthPKI)
read an ASN.1 hexadecimal string of X.509 ECC public key certificate
 
read an ASN.1 hexadecimal string of PKCS#1/5 plain ECC private key
 
read an ASN.1 hexadecimal string of PKCS#8 plain ECC private key
 
read an ASN.1 hexadecimal string of PKCS#8 ECC public key
 
signHex(hashHex, privHex)
signing to message hash
 
verifyHex(hashHex, sigHex, pubkeyHex)
verifying signature with message hash and public key
Class Detail
KJUR.crypto.ECDSA()
class for EC key generation, ECDSA signing and verifcation

CAUTION: Most of the case, you don't need to use this class except for generating an EC key pair. Please use KJUR.crypto.Signature class instead.

This class was originally developped by Stefan Thomas for Bitcoin JavaScript library. (See https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js) Currently this class supports following named curves and their aliases.

  • secp256r1, NIST P-256, P-256, prime256v1 (*)
  • secp256k1 (*)
  • secp384r1, NIST P-384, P-384 (*)

Method Detail
<static> {String} KJUR.crypto.ECDSA.asn1SigToConcatSig(asn1Hex)
convert hexadecimal ASN.1 encoded signature to concatinated signature
Parameters:
{String} asn1Hex
hexadecimal string of ASN.1 encoded ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} r-s concatinated format of ECDSA signature value

<static> {String} KJUR.crypto.ECDSA.biRSSigToASN1Sig(biR, biS)
convert R and S BigInteger object of signature to ASN.1 encoded signature
Parameters:
{BigInteger} biR
BigInteger object of R field of ECDSA signature value
{BigInteger} biS
BIgInteger object of S field of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

<static> {String} KJUR.crypto.ECDSA.concatSigToASN1Sig(concatSig)
convert hexadecimal concatinated signature to ASN.1 encoded signature
Parameters:
{String} concatSig
r-s concatinated format of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

{Array} generateKeyPairHex()
generate a EC key pair
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var keypair = ec.generateKeyPairHex();
var pubhex = keypair.ecpubhex; // hexadecimal string of EC public key
var prvhex = keypair.ecprvhex; // hexadecimal string of EC private key (=d)
Since:
ecdsa-modified 1.0.1
Returns:
{Array} associative array of hexadecimal string of private and public key

<static> {String} KJUR.crypto.ECDSA.getName(s)
static method to get normalized EC curve name from curve name or hexadecimal OID value This static method returns normalized EC curve name which is supported in jsrsasign from curve name or hexadecimal OID value. When curve is not supported in jsrsasign, this method returns null. Normalized name will be "secp*" in jsrsasign.
KJUR.crypto.ECDSA.getName("2b8104000a") → "secp256k1"
KJUR.crypto.ECDSA.getName("NIST P-256") → "secp256r1"
KJUR.crypto.ECDSA.getName("P-521") → undefined // not supported
Parameters:
{String} s
curve name (ex. P-256) or hexadecimal OID value (ex. 2a86...)
Since:
jsrsasign 7.1.0 ecdsa-modified 1.1.0
Returns:
{String} normalized EC curve name (ex. secp256r1)

{Array} getPublicKeyXYHex()
get X and Y hexadecimal string value of public key
ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'pub': pubHex});
ec.getPublicKeyXYHex() → { x: '01bacf...', y: 'c3bc22...' }
Since:
ecdsa-modified 1.0.5 jsrsasign 5.0.14
Returns:
{Array} associative array of x and y value of public key

{String} getShortNISTPCurveName()
get NIST curve short name such as "P-256" or "P-384"
ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'pub': pubHex});
ec.getShortPCurveName() → "P-256";
Since:
ecdsa-modified 1.0.5 jsrsasign 5.0.14
Returns:
{String} short NIST P curve name such as "P-256" or "P-384" if it's NIST P curve otherwise null;

<static> {String} KJUR.crypto.ECDSA.hexRSSigToASN1Sig(hR, hS)
convert hexadecimal R and S value of signature to ASN.1 encoded signature
Parameters:
{String} hR
hexadecimal string of R field of ECDSA signature value
{String} hS
hexadecimal string of S field of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

<static> {Array} KJUR.crypto.ECDSA.parseSigHex(sigHex)
parse ASN.1 DER encoded ECDSA signature
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sig = ec.parseSigHex('30...');
var biR = sig.r; // BigInteger object for 'r' field of signature.
var biS = sig.s; // BigInteger object for 's' field of signature.
Parameters:
{String} sigHex
hexadecimal string of ECDSA signature value
Since:
ecdsa-modified 1.0.1
Returns:
{Array} associative array of signature field r and s of BigInteger

<static> {Array} KJUR.crypto.ECDSA.parseSigHexInHexRS(sigHex)
parse ASN.1 DER encoded ECDSA signature
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sig = ec.parseSigHexInHexRS('30...');
var hR = sig.r; // hexadecimal string for 'r' field of signature.
var hS = sig.s; // hexadecimal string for 's' field of signature.
Parameters:
{String} sigHex
hexadecimal string of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{Array} associative array of signature field r and s in hexadecimal

readCertPubKeyHex(h, nthPKI)
read an ASN.1 hexadecimal string of X.509 ECC public key certificate
Parameters:
{String} h
hexadecimal string of X.509 ECC public key certificate
{Integer} nthPKI
nth index of publicKeyInfo. (DEFAULT: 6 for X509v3)
Since:
jsrsasign 7.1.0 ecdsa-modified 1.1.0

readPKCS5PrvKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#1/5 plain ECC private key
Parameters:
{String} h
hexadecimal string of PKCS#1/5 ECC private key
Since:
jsrsasign 7.1.0 ecdsa-modified 1.1.0

readPKCS8PrvKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#8 plain ECC private key
Parameters:
{String} h
hexadecimal string of PKCS#8 ECC private key
Since:
jsrsasign 7.1.0 ecdsa-modified 1.1.0

readPKCS8PubKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#8 ECC public key
Parameters:
{String} h
hexadecimal string of PKCS#8 ECC public key
Since:
jsrsasign 7.1.0 ecdsa-modified 1.1.0

{String} signHex(hashHex, privHex)
signing to message hash
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sigValue = ec.signHex(hash, prvKey);
Parameters:
{String} hashHex
hexadecimal string of hash value of signing message
{String} privHex
hexadecimal string of EC private key
Since:
ecdsa-modified 1.0.1
Returns:
{String} hexadecimal string of ECDSA signature

{Boolean} verifyHex(hashHex, sigHex, pubkeyHex)
verifying signature with message hash and public key
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var result = ec.verifyHex(msgHashHex, sigHex, pubkeyHex);
Parameters:
{String} hashHex
hexadecimal string of hash value of signing message
{String} sigHex
hexadecimal string of signature value
{String} pubkeyHex
hexadecimal string of public key
Since:
ecdsa-modified 1.0.1
Returns:
{Boolean} true if the signature is valid, otherwise false

© 2012-2016 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0