@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
118 lines (117 loc) • 3.93 kB
JavaScript
import * as $ from "@wildboar/asn1/functional";
/**
* @summary KeyInfo_paramsAndOps
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* KeyInfo-paramsAndOps ::= SEQUENCE { -- REMOVED_FROM_UNNESTING -- }
* ```
*
*/
export class KeyInfo_paramsAndOps {
parameters;
supportedOperations;
constructor(
/**
* @summary `parameters`.
* @public
* @readonly
*/
parameters,
/**
* @summary `supportedOperations`.
* @public
* @readonly
*/
supportedOperations) {
this.parameters = parameters;
this.supportedOperations = supportedOperations;
}
/**
* @summary Restructures an object into a KeyInfo_paramsAndOps
* @description
*
* This takes an `object` and converts it to a `KeyInfo_paramsAndOps`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `KeyInfo_paramsAndOps`.
* @returns {KeyInfo_paramsAndOps}
*/
static _from_object(_o) {
return new KeyInfo_paramsAndOps(_o.parameters, _o.supportedOperations);
}
}
/**
* @summary The Leading Root Component Types of KeyInfo_paramsAndOps
* @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_KeyInfo_paramsAndOps = [
new $.ComponentSpec("parameters", false, $.hasAnyTag),
new $.ComponentSpec("supportedOperations", true, $.hasAnyTag),
];
/**
* @summary The Trailing Root Component Types of KeyInfo_paramsAndOps
* @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_KeyInfo_paramsAndOps = [];
/**
* @summary The Extension Addition Component Types of KeyInfo_paramsAndOps
* @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_KeyInfo_paramsAndOps = [];
/**
* @summary Returns a function that will decode an ASN.1 element into a(n) KeyInfo_paramsAndOps
* @function
* @param {_Element} el The element being decoded.
* @returns A function that will decode an ASN.1 element.
*/
export function _get_decoder_for_KeyInfo_paramsAndOps(_decode_ParameterType, _decode_OperationsType) {
return function (el) {
let parameters;
let supportedOperations;
const callbacks = {
parameters: (_el) => {
parameters = _decode_ParameterType(_el);
},
supportedOperations: (_el) => {
supportedOperations = _decode_OperationsType(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_KeyInfo_paramsAndOps, _extension_additions_list_spec_for_KeyInfo_paramsAndOps, _root_component_type_list_2_spec_for_KeyInfo_paramsAndOps, undefined);
return new KeyInfo_paramsAndOps(parameters, supportedOperations);
};
}
/**
* @summary Returns a function that will encode a(n) KeyInfo_paramsAndOps into an ASN.1 Element.
* @function
* @returns A function that will encode a(n) KeyInfo_paramsAndOps as an ASN.1 element.
*/
export function _get_encoder_for_KeyInfo_paramsAndOps(_encode_ParameterType, _encode_OperationsType) {
return function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ _encode_ParameterType(value.parameters, $.BER),
/* IF_ABSENT */ value.supportedOperations === undefined
? undefined
: _encode_OperationsType(value.supportedOperations, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
/* eslint-enable */