jsrsasign - RSA Signing and Verification in JavaScript

Kenji Urushima
Last Update: Apr 30, 2012

The 'jsrsasign'(RSA-Sign JavaScript Library) is a open source free pure JavaScript implementation of PKCS#1 v2.1 RSASSA-PKCS1-v1_5 RSA signing and validation algorithm.

NEWS

Release 1.2 is now available on Apr 30, 2012 for fixing critical zero padding bug and supporting some other hash functions.

DEMO

SOURCE CODES

The 'rsa-sign' library contains following source codes.

LICENSE

The 'jsrsasign'(RSA-Sign JavaScript Library) is licensed under the terms of the MIT license reproduced below.

How to sign

var rsa = new RSAKey(); rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_); var hSig = rsa.signString("aaa", "sha1"); // sign a string "aaa" with key

How to verify signature

vr x509 = new X509(); x509.readCertPEM(_PEM_X509CERT_STRING_); var result = x509.subjectPublicKeyRSA.verifyString("aaa", _HEX_SIGNATURE_);

How to add supported signature algorithms

The script "rsa-sign.js" currently supports SHA1withRSA, SHA256withRSA, SHA512withRSA, MD5withRSA and RIPEMD160withRSA signature algorithms. However you can extend other signature algorithms such like MD2withRSA or SHA384withRSA by just specifying two variables in it.
_RSASIGN_DIHEAD['md2'] = "30..."; // Hexadecimal DigestInfo prefix for MD5 _RSASIGN_HASHHEXFUNC['md2'] = md2hex; // function which returns value in hex.

Required Third Party Source Codes

Release

See 'ChangeLog.txt' in detail.

Copyright © 2010-2012 Kenji Urushima. All rights reserved.