Home Reference Source
import EnvelopedData from 'pkijs/src/EnvelopedData.js'
public class | source

EnvelopedData

Class from RFC5652

Static Method Summary

Static Public Methods
public static

compareWithDefault(memberName: string, memberValue: *): *

Compare values with default values for all class members

public static

defaultValues(memberName: string): *[]

Return default values for all class members

public static

schema(parameters: Object): Object

Return value of asn1js schema for current class

Constructor Summary

Public Constructor
public

constructor(parameters: Object)

Constructor for EnvelopedData class

Member Summary

Public Members
public
public
public
public
public

Method Summary

Public Methods
public

addRecipientByCertificate(certificate: Certificate, parameters: Object, variant: number): boolean

Helpers function for filling "RecipientInfo" based on recipient's certificate. Problem with WebCrypto is that for RSA certificates we have only one option - "key transport" and for ECC certificates we also have one option - "key agreement". As soon as Google will implement DH algorithm it would be possible to use "key agreement" also for RSA certificates.

public

addRecipientByPreDefinedData(preDefinedData: ArrayBuffer, parameters: Object, variant: number)

Add recipient based on pre-defined data like password or KEK

public

decrypt(recipientIndex: number, parameters: Object): Promise

Decrypt existing CMS Enveloped Data content

public

encrypt(contentEncryptionAlgorithm: Object, contentToEncrypt: ArrayBuffer): Promise

Create a new CMS Enveloped Data content with encrypted data

public

fromSchema(schema: Object)

Convert parsed asn1js object into current class

public

Convertion for the class to JSON object

public

Convert current object to asn1js object and set correct values

Static Public Methods

public static compareWithDefault(memberName: string, memberValue: *): * source

Compare values with default values for all class members

Params:

NameTypeAttributeDescription
memberName string

String name for a class member

memberValue *

Value to compare with default value

Return:

*

public static defaultValues(memberName: string): *[] source

Return default values for all class members

Params:

NameTypeAttributeDescription
memberName string

String name for a class member

Return:

*[]

public static schema(parameters: Object): Object source

Return value of asn1js schema for current class

Params:

NameTypeAttributeDescription
parameters Object

Input parameters for the schema

Return:

Object

asn1js schema object

Public Constructors

public constructor(parameters: Object) source

Constructor for EnvelopedData class

Params:

NameTypeAttributeDescription
parameters Object
  • optional
  • default: {}

Public Members

public encryptedContentInfo: EncryptedContentInfo source

public originatorInfo: OriginatorInfo source

public recipientInfos: Array<RecipientInfo> source

public unprotectedAttrs: Array<Attribute> source

public version: number source

Public Methods

public addRecipientByCertificate(certificate: Certificate, parameters: Object, variant: number): boolean source

Helpers function for filling "RecipientInfo" based on recipient's certificate. Problem with WebCrypto is that for RSA certificates we have only one option - "key transport" and for ECC certificates we also have one option - "key agreement". As soon as Google will implement DH algorithm it would be possible to use "key agreement" also for RSA certificates.

Params:

NameTypeAttributeDescription
certificate Certificate
  • optional

Recipient's certificate

parameters Object
  • optional

Additional parameters neccessary for "fine tunning" of encryption process

variant number
  • optional

Variant = 1 is for "key transport", variant = 2 is for "key agreement". In fact the "variant" is unneccessary now because Google has no DH algorithm implementation. Thus key encryption scheme would be choosen by certificate type only: "key transport" for RSA and "key agreement" for ECC certificates.

Return:

boolean

public addRecipientByPreDefinedData(preDefinedData: ArrayBuffer, parameters: Object, variant: number) source

Add recipient based on pre-defined data like password or KEK

Params:

NameTypeAttributeDescription
preDefinedData ArrayBuffer

ArrayBuffer with pre-defined data

parameters Object

Additional parameters neccessary for "fine tunning" of encryption process

variant number

Variant = 1 for pre-defined "key encryption key" (KEK). Variant = 2 for password-based encryption.

public decrypt(recipientIndex: number, parameters: Object): Promise source

Decrypt existing CMS Enveloped Data content

Params:

NameTypeAttributeDescription
recipientIndex number

Index of recipient

parameters Object

Additional parameters

Return:

Promise

public encrypt(contentEncryptionAlgorithm: Object, contentToEncrypt: ArrayBuffer): Promise source

Create a new CMS Enveloped Data content with encrypted data

Params:

NameTypeAttributeDescription
contentEncryptionAlgorithm Object

WebCrypto algorithm. For the moment here could be only "AES-CBC" or "AES-GCM" algorithms.

contentToEncrypt ArrayBuffer

Content to encrypt

Return:

Promise

public fromSchema(schema: Object) source

Convert parsed asn1js object into current class

Params:

NameTypeAttributeDescription
schema Object
  • nullable: false

public toJSON(): Object source

Convertion for the class to JSON object

Return:

Object

public toSchema(): Object source

Convert current object to asn1js object and set correct values

Return:

Object

asn1js object