node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey ยป



This module will create a private_key container object according to the specifications in the SDMP protocol.


This module is made to use npm. Install the normal npm way:

npm install sdmp-create-private-key

use it

You must pass in a node-rsa object containing a private key of 2048 bits:

var create = require('sdmp-create-private-key')
var container = create(nodeRsaPrivateKey)
// container is a valid `private_key` container object, e,g,
console.log(container.private_key.key) // => -----BEGIN RSA PRIVATE KEY-----...


The node-rsa module is an RSA crypto module implemented in pure JavaScript. This gives maximum portability, but generating keys in JS is not as fast as system-native libraries.

You can create a node-rsa private key object any of the following ways:

new key

var NodeRSA = require('node-rsa')
var nodeRsaPrivateKey = new NodeRSA({ b: 2048 })

from PEM encoded string

var NodeRSA = require('node-rsa')
var pemKey = '-----BEGIN RSA PRIVATE KEY-----\n...'
var nodeRsaPrivateKey = new NodeRSA(pemKey)

api create(nodeRsaPrivateKey[, unixOffsetToExpire])

In all cases, calling the function will either return a new container object, or throw an exception.

nodeRsaPrivateKey (object, required)

The parameter nodeRsaPrivateKey must be a node-rsa equivalent object, containing a private key of 2048 bytes.

unixOffsetToExpire (integer, optional)

Pass in the unix offset (milliseconds since Unix Epoch) and the UTC expiration date will be set to that exact date.

If this value is not set, the expiration date will be set to five years in the future.


Published and released under the Very Open License.