@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
132 lines (131 loc) • 4.24 kB
JavaScript
/* eslint-disable */
import { ASN1ConstructionError as _ConstructionError, ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
/**
* @summary RC2CBCParameter
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* RC2CBCParameter ::= SEQUENCE {
* rc2ParameterVersion INTEGER,
* iv OCTET STRING
* }
* ```
*
*/
export class RC2CBCParameter {
rc2ParameterVersion;
iv;
constructor(
/**
* @summary `rc2ParameterVersion`.
* @public
* @readonly
*/
rc2ParameterVersion,
/**
* @summary `iv`.
* @public
* @readonly
*/
iv) {
this.rc2ParameterVersion = rc2ParameterVersion;
this.iv = iv;
}
/**
* @summary Restructures an object into a RC2CBCParameter
* @description
*
* This takes an `object` and converts it to a `RC2CBCParameter`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `RC2CBCParameter`.
* @returns {RC2CBCParameter}
*/
static _from_object(_o) {
return new RC2CBCParameter(_o.rc2ParameterVersion, _o.iv);
}
}
/**
* @summary The Leading Root Component Types of RC2CBCParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_1_spec_for_RC2CBCParameter = [
new $.ComponentSpec("rc2ParameterVersion", false, $.hasTag(_TagClass.universal, 2)),
new $.ComponentSpec("iv", false, $.hasTag(_TagClass.universal, 4)),
];
/**
* @summary The Trailing Root Component Types of RC2CBCParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_2_spec_for_RC2CBCParameter = [];
/**
* @summary The Extension Addition Component Types of RC2CBCParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _extension_additions_list_spec_for_RC2CBCParameter = [];
let _cached_decoder_for_RC2CBCParameter = null;
/**
* @summary Decodes an ASN.1 element into a(n) RC2CBCParameter
* @function
* @param {_Element} el The element being decoded.
* @returns {RC2CBCParameter} The decoded data structure.
*/
export function _decode_RC2CBCParameter(el) {
if (!_cached_decoder_for_RC2CBCParameter) {
_cached_decoder_for_RC2CBCParameter = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new _ConstructionError("RC2CBCParameter contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "rc2ParameterVersion";
sequence[1].name = "iv";
let rc2ParameterVersion;
let iv;
rc2ParameterVersion = $._decodeInteger(sequence[0]);
iv = $._decodeOctetString(sequence[1]);
return new RC2CBCParameter(rc2ParameterVersion, iv);
};
}
return _cached_decoder_for_RC2CBCParameter(el);
}
let _cached_encoder_for_RC2CBCParameter = null;
/**
* @summary Encodes a(n) RC2CBCParameter into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The RC2CBCParameter, encoded as an ASN.1 Element.
*/
export function _encode_RC2CBCParameter(value, elGetter) {
if (!_cached_encoder_for_RC2CBCParameter) {
_cached_encoder_for_RC2CBCParameter = function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeInteger(value.rc2ParameterVersion, $.BER),
/* REQUIRED */ $._encodeOctetString(value.iv, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_RC2CBCParameter(value, elGetter);
}
/* eslint-enable */