# Module: crypto/pkcs1

Provides EME-PKCS1-v1_5 encoding and decoding and EMSA-PKCS1-v1_5 encoding function

Source:
  - crypto/pkcs1.js, line 18
See:
  - module:crypto/public_key/rsa
  - module:crypto/public_key/elliptic/ecdh
  - PublicKeyEncryptedSessionKeyPacket

### Members

#### (inner, constant) hash_headers

ASN1 object identifiers for hashes

Source:
  - crypto/pkcs1.js, line 34
See:
  - https://tools.ietf.org/html/rfc4880#section-5.2.2

### Methods

#### (static) emeDecode(encoded, randomPayload) → {Uint8Array}

Decode a EME-PKCS1-v1_5 padded message

##### Parameters:

Name | Type | Description
--- | --- | ---
`encoded` | Uint8Array | Encoded message bytes
`randomPayload` | Uint8Array | Data to return in case of decoding error (needed for constant-time processing)

Source:
  - crypto/pkcs1.js, line 103
See:
  - RFC 4880 13.1.2

##### Throws:

on decoding failure, unless `randomPayload` is provided

Type
  Error

##### Returns:

decoded data or `randomPayload` (on error, if given)

Type
  Uint8Array

#### (static) emeEncode(message, keyLength) → {Uint8Array}

Create a EME-PKCS1-v1_5 padded message

##### Parameters:

Name | Type | Description
--- | --- | ---
`message` | Uint8Array | Message to be encoded
`keyLength` | Integer | The length in octets of the key modulus

Source:
  - crypto/pkcs1.js, line 75
See:
  - RFC 4880 13.1.1

##### Returns:

EME-PKCS1 padded message.

Type
  Uint8Array

#### (static) emsaEncode(algo, hashed, emLen) → {Uint8Array}

Create a EMSA-PKCS1-v1_5 padded message

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | Integer | Hash algorithm type used
`hashed` | Uint8Array | Message to be encoded
`emLen` | Integer | Intended length in octets of the encoded message

Source:
  - crypto/pkcs1.js, line 135
See:
  - RFC 4880 13.1.3

##### Returns:

Encoded message.

Type
  Uint8Array