Skip to content

Commit

Permalink
updated documentation to cover support for defaulting padding modes i…
Browse files Browse the repository at this point in the history
…n javascript layer
  • Loading branch information
krisb committed Feb 10, 2013
1 parent f694e2d commit 0df5eca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -84,9 +84,10 @@ This default may be overridden to use the older mode `RSA_PKCS1_PADDING`
if needed.

The less well-understood private-encryption / public-decryption operations
(used for building signature mechanisms) are always done using padding
(used for building signature mechanisms) by default use padding
mode `RSA_PKCS1_PADDING`. This doesn't build in any randomness (but that's
not usually a problem for applications that use these operations).
not usually a problem for applications that use these operations). This
default may be overridden to use `RSA_NO_PADDING` if needed.

See the doc comments and tests for the excruciating details, but here's
a quick rundown of the available top-level exports and instance methods:
Expand Down Expand Up @@ -288,8 +289,8 @@ key associated with the instance. (For example, if the key is 2048
bits, then the result of this operation will be no more than 2048
bits, aka 256 bytes.)

This operation is always performed using padding mode
`RSA_PKCS1_PADDING`.
If no padding mode is specified, the default, and recommended, mode
is `ursa.RSA_PKCS1_PADDING`. The mode `ursa.RSA_NO_PADDING` is also supported.

### toPublicPem(encoding)

Expand Down Expand Up @@ -376,8 +377,8 @@ then the result of this operation will be 2048 bits, aka 256 bytes.)
The input buffer is limited to be no larger than the key size
minus 12 bytes.

This operation is always performed using padding mode
`RSA_PKCS1_PADDING`.
If no padding mode is specified, the default, and recommended, mode
is `ursa.RSA_PKCS1_PADDING`. The mode `ursa.RSA_NO_PADDING` is also supported.

### sign(algorithm, hash, hashEncoding, outEncoding)

Expand Down Expand Up @@ -442,10 +443,10 @@ other cases.
Constants
---------

Allowed padding modes for public encryption and
private decryption:
Allowed padding modes for public/private encryption/decryption:

* `ursa.RSA_PKCS1_PADDING`
* `ursa.RSA_NO_PADDING`
* `ursa.RSA_PKCS1_OAEP_PADDING`


Expand Down
10 changes: 4 additions & 6 deletions src/ursaNative.cc
Expand Up @@ -624,8 +624,7 @@ Handle<Value> RsaWrap::GetPublicKeyPem(const Arguments& args) {

/**
* Perform decryption on the given buffer using the RSA key, which
* must be a private key. This always uses the padding mode
* RSA_PKCS1_OAEP_PADDING.
* must be a private key, and padding mode.
*/
Handle<Value> RsaWrap::PrivateDecrypt(const Arguments& args) {
HandleScope scope;
Expand Down Expand Up @@ -664,8 +663,7 @@ Handle<Value> RsaWrap::PrivateDecrypt(const Arguments& args) {

/**
* Perform encryption on the given buffer using the RSA key, which
* must be private. This always uses the padding mode
* RSA_PKCS1_PADDING.
* must be private, and padding mode.
*/
Handle<Value> RsaWrap::PrivateEncrypt(const Arguments& args) {
HandleScope scope;
Expand Down Expand Up @@ -703,7 +701,7 @@ Handle<Value> RsaWrap::PrivateEncrypt(const Arguments& args) {

/**
* Perform decryption on the given buffer using the (public aspect of
* the) RSA key. This always uses the padding mode RSA_PKCS1_PADDING.
* the) RSA key, and padding mode.
*/
Handle<Value> RsaWrap::PublicDecrypt(const Arguments& args) {
HandleScope scope;
Expand Down Expand Up @@ -742,7 +740,7 @@ Handle<Value> RsaWrap::PublicDecrypt(const Arguments& args) {

/**
* Perform encryption on the given buffer using the public (aspect of the)
* RSA key. This always uses the padding mode RSA_PKCS1_OAEP_PADDING.
* RSA key, and padding mode.
*/
Handle<Value> RsaWrap::PublicEncrypt(const Arguments& args) {
HandleScope scope;
Expand Down

0 comments on commit 0df5eca

Please sign in to comment.