Class Index | File Index

Classes


Class RSAKey

key of RSA public key algorithm
Defined in: rsasign-1.2.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
RSAKey()
Tom Wu's RSA Key class and extension
Method Summary
Method Attributes Method Name and Description
<static>  
RSAKey.getHexValueArrayOfChildrenFromHex(sPEMPrivateKey)
static method to get array of hex field values from hexadecimal PKCS#5 RSA private key.
<static>  
RSAKey.getPosArrayOfChildrenFromHex(sPEMPrivateKey)
static method to get array of field positions from hexadecimal PKCS#5 RSA private key.
 
readCertPubKeyHex(h, nthPKI)
read an ASN.1 hexadecimal string of X.509 RSA public key certificate
 
read an ASN.1 hexadecimal string of PKCS#1/5 plain RSA private key
 
read an ASN.1 hexadecimal string of PKCS#5 RSA public key
 
read an ASN.1 hexadecimal string of PKCS#8 plain RSA private key
 
read an ASN.1 hexadecimal string of PKCS#8 RSA public key
 
read PKCS#1 private key from a string
<static>  
RSAKey.sign(s, hashAlg)
sign for a message string with RSA private key.
<static>  
RSAKey.signPSS(s, hashAlg, sLen)
sign for a message string with RSA private key by PKCS#1 PSS signing.
<static>  
RSAKey.signWithMessageHash(sHashHex, hashAlg)
sign hash value of message to be signed with RSA private key.
<static>  
RSAKey.signWithMessageHashPSS(hHash, hashAlg, sLen)
sign hash value of message with RSA private key by PKCS#1 PSS signing.
 
verify(sMsg, hSig)
verifies a sigature for a message string with RSA public key.
<static>  
RSAKey.verifyPSS(sMsg, hSig, hashAlg, sLen)
verifies a sigature for a message string with RSA public key by PKCS#1 PSS sign.
<static>  
RSAKey.verifyWithMessageHash(sHashHex, hSig)
verifies a sigature for a message string with RSA public key.
<static>  
RSAKey.verifyWithMessageHashPSS(hHash, hSig, hashAlg, sLen)
verifies a sigature for a hash value of message string with RSA public key by PKCS#1 PSS sign.
Class Detail
RSAKey()
Tom Wu's RSA Key class and extension
Method Detail
<static> {Array} RSAKey.getHexValueArrayOfChildrenFromHex(sPEMPrivateKey)
static method to get array of hex field values from hexadecimal PKCS#5 RSA private key.

Defined in: rsapem-1.1.js.
RSAKey.getHexValueArrayOfChildrenFromHex("3082...") → ["00", "3b42...", ...]
Parameters:
{String} sPEMPrivateKey
PEM PKCS#1/5 s private key string
Returns:
{Array} array of field hex value

<static> {Array} RSAKey.getPosArrayOfChildrenFromHex(sPEMPrivateKey)
static method to get array of field positions from hexadecimal PKCS#5 RSA private key.

Defined in: rsapem-1.1.js.
RSAKey.getPosArrayOfChildrenFromHex("3082...") → [8, 32, ...]
Parameters:
{String} sPEMPrivateKey
PEM PKCS#1/5 s private key string
Returns:
{Array} array of field positions

readCertPubKeyHex(h, nthPKI)
read an ASN.1 hexadecimal string of X.509 RSA public key certificate

Defined in: rsapem-1.1.js.
Parameters:
{String} h
hexadecimal string of X.509 RSA public key certificate
{Integer} nthPKI
nth index of publicKeyInfo. (DEFAULT: 6 for X509v3)
Since:
jsrsasign 7.1.0 rsapem 1.2.0

readPKCS5PrvKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#1/5 plain RSA private key

Defined in: rsapem-1.1.js.
Parameters:
{String} h
hexadecimal string of PKCS#1/5 plain RSA private key
Since:
jsrsasign 7.1.0 rsapem 1.2.0
See:
former method

readPKCS5PubKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#5 RSA public key

Defined in: rsapem-1.1.js.
Parameters:
{String} h
hexadecimal string of PKCS#5 public key
Since:
jsrsasign 7.1.0 rsapem 1.2.0

readPKCS8PrvKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#8 plain RSA private key

Defined in: rsapem-1.1.js.
Parameters:
{String} h
hexadecimal string of PKCS#8 plain RSA private key
Since:
jsrsasign 7.1.0 rsapem 1.2.0

readPKCS8PubKeyHex(h)
read an ASN.1 hexadecimal string of PKCS#8 RSA public key

Defined in: rsapem-1.1.js.
Parameters:
{String} h
hexadecimal string of PKCS#8 public key
Since:
jsrsasign 7.1.0 rsapem 1.2.0

readPrivateKeyFromPEMString(keyPEM)
read PKCS#1 private key from a string

Defined in: rsapem-1.1.js.
Parameters:
{String} keyPEM
string of PKCS#1 private key.

<static> RSAKey.sign(s, hashAlg)
sign for a message string with RSA private key.
Parameters:
{String} s
message string to be signed.
{String} hashAlg
hash algorithm name for signing.
Returns:
returns hexadecimal string of signature value.

<static> RSAKey.signPSS(s, hashAlg, sLen)
sign for a message string with RSA private key by PKCS#1 PSS signing.
Parameters:
{String} s
message string to be signed.
{String} hashAlg
hash algorithm name for signing.
{Integer} sLen
salt byte length from 0 to (keybytelen - hashbytelen - 2). There are two special values:
  • -1: sets the salt length to the digest length
  • -2: sets the salt length to maximum permissible value (i.e. keybytelen - hashbytelen - 2)
DEFAULT is -1. (NOTE: OpenSSL's default is -2.)
Returns:
returns hexadecimal string of signature value.

<static> RSAKey.signWithMessageHash(sHashHex, hashAlg)
sign hash value of message to be signed with RSA private key.
Parameters:
{String} sHashHex
hexadecimal string of hash value of message to be signed.
{String} hashAlg
hash algorithm name for signing.
Since:
rsasign 1.2.6
Returns:
returns hexadecimal string of signature value.

<static> RSAKey.signWithMessageHashPSS(hHash, hashAlg, sLen)
sign hash value of message with RSA private key by PKCS#1 PSS signing.
Parameters:
{String} hHash
hexadecimal hash value of message to be signed.
{String} hashAlg
hash algorithm name for signing.
{Integer} sLen
salt byte length from 0 to (keybytelen - hashbytelen - 2). There are two special values:
  • -1: sets the salt length to the digest length
  • -2: sets the salt length to maximum permissible value (i.e. keybytelen - hashbytelen - 2)
DEFAULT is -1. (NOTE: OpenSSL's default is -2.)
Since:
rsasign 1.2.6
Returns:
returns hexadecimal string of signature value.

verify(sMsg, hSig)
verifies a sigature for a message string with RSA public key.
This method verifies RSA signature with raw message string and hexadecimal signature value.
pubkey = new RSAKey();
pubkey.setPublic("1abd...", "10001");
pubkey.verify("hello world", "3da1...") → true or false
Parameters:
{String} sMsg
raw message string to be verified.
{String} hSig
hexadecimal string of siganture.
non-hexadecimal charactors including new lines will be ignored.
Returns:
returns true if valid, otherwise false

<static> RSAKey.verifyPSS(sMsg, hSig, hashAlg, sLen)
verifies a sigature for a message string with RSA public key by PKCS#1 PSS sign.
Parameters:
{String} sMsg
message string to be verified.
{String} hSig
hexadecimal string of signature value
{String} hashAlg
hash algorithm name
{Integer} sLen
salt byte length from 0 to (keybytelen - hashbytelen - 2). There are two special values:
  • -1: sets the salt length to the digest length
  • -2: sets the salt length to maximum permissible value (i.e. keybytelen - hashbytelen - 2)
DEFAULT is -1. (NOTE: OpenSSL's default is -2.)
Returns:
returns true if valid, otherwise false

<static> RSAKey.verifyWithMessageHash(sHashHex, hSig)
verifies a sigature for a message string with RSA public key.
Parameters:
{String} sHashHex
hexadecimal hash value of message to be verified.
{String} hSig
hexadecimal string of siganture.
non-hexadecimal charactors including new lines will be ignored.
Since:
rsasign 1.2.6
Returns:
returns 1 if valid, otherwise 0

<static> RSAKey.verifyWithMessageHashPSS(hHash, hSig, hashAlg, sLen)
verifies a sigature for a hash value of message string with RSA public key by PKCS#1 PSS sign.
Parameters:
{String} hHash
hexadecimal hash value of message string to be verified.
{String} hSig
hexadecimal string of signature value
{String} hashAlg
hash algorithm name
{Integer} sLen
salt byte length from 0 to (keybytelen - hashbytelen - 2). There are two special values:
  • -1: sets the salt length to the digest length
  • -2: sets the salt length to maximum permissible value (i.e. keybytelen - hashbytelen - 2)
DEFAULT is -1 (NOTE: OpenSSL's default is -2.)
Since:
rsasign 1.2.6
Returns:
returns true if valid, otherwise false

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