The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES and JSON Web Signature/Token in pure JavaScript.
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQKrpju2waIQ+oZEke2kI5Tt1i
aPPmAwOjxXLyUKoi+qNWrTNQL+6/1/SDFHeBoDT4I7Ann6TFDYAkqLSSjKFYXoBK
n3P+e5RAaTzSsUBncqko9Ytqr0vED3Wn+ZYkjmEMEmIJhyYMTD/Wkk3tVrNC9ZdC
I4HpblSqdGb6pnEm1wIDAQAB
-----END PUBLIC KEY-----
// Output public key
console.log(KEYUTIL.getPEM(rsaKeypair.pubKeyObj));
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQKrpju2waIQ+oZEke2kI5Tt1i
aPPmAwOjxXLyUKoi+qNWrTNQL+6/1/SDFHeBoDT4I7Ann6TFDYAkqLSSjKFYXoBK
n3P+e5RAaTzSsUBncqko9Ytqr0vED3Wn+ZYkjmEMEmIJhyYMTD/Wkk3tVrNC9ZdC
I4HpblSqdGb6pnEm1wIDAQAB
-----END PUBLIC KEY-----
prvKeyObj shows true for public key and private key:
prvKeyObj: Object { e: 65537, isPrivate: true, isPublic: true, … }
pubKeyObj shows (correct?) bools for isPublic and isPrivate:
pubKeyObj: Object { e: 65537, isPublic: true, isPrivate: false, … }
Running generateKeypair seems to create two public keys.
// Generate private/public key pair var rsaKeypair = KEYUTIL.generateKeypair("RSA", 1024);
// Output private key console.log(KEYUTIL.getPEM(rsaKeypair.prvKeyObj));
-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQKrpju2waIQ+oZEke2kI5Tt1i aPPmAwOjxXLyUKoi+qNWrTNQL+6/1/SDFHeBoDT4I7Ann6TFDYAkqLSSjKFYXoBK n3P+e5RAaTzSsUBncqko9Ytqr0vED3Wn+ZYkjmEMEmIJhyYMTD/Wkk3tVrNC9ZdC I4HpblSqdGb6pnEm1wIDAQAB -----END PUBLIC KEY-----
// Output public key console.log(KEYUTIL.getPEM(rsaKeypair.pubKeyObj));
-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQKrpju2waIQ+oZEke2kI5Tt1i aPPmAwOjxXLyUKoi+qNWrTNQL+6/1/SDFHeBoDT4I7Ann6TFDYAkqLSSjKFYXoBK n3P+e5RAaTzSsUBncqko9Ytqr0vED3Wn+ZYkjmEMEmIJhyYMTD/Wkk3tVrNC9ZdC I4HpblSqdGb6pnEm1wIDAQAB -----END PUBLIC KEY-----
prvKeyObj shows true for public key and private key: prvKeyObj: Object { e: 65537, isPrivate: true, isPublic: true, … }
pubKeyObj shows (correct?) bools for isPublic and isPrivate: pubKeyObj: Object { e: 65537, isPublic: true, isPrivate: false, … }