import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import * as common from "./common"; import { EncryptedContentInfo, EncryptedContentInfoJson, EncryptedContentInfoSchema } from "./EncryptedContentInfo"; import { Attribute, AttributeJson } from "./Attribute"; import * as Schema from "./Schema"; import { ArgumentError, AsnError } from "./errors"; import { CryptoEngineEncryptParams } from "./CryptoEngine/CryptoEngineInterface"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import { EMPTY_STRING } from "./constants";
export interface IEncryptedData { /** * Version number. * * If `unprotectedAttrs` is present, then the version MUST be 2. If `unprotectedAttrs` is absent, then version MUST be 0.
*/
version: number; /** * Encrypted content information
*/
encryptedContentInfo: EncryptedContentInfo; /** * Collection of attributes that are not encrypted
*/
unprotectedAttrs?: Attribute[];
}
public version!: number; public encryptedContentInfo!: EncryptedContentInfo; public unprotectedAttrs?: Attribute[];
/** * Initializes a new instance of the {@link EncryptedData} class * @param parameters Initialization parameters
*/
constructor(parameters: EncryptedDataParameters = {}) { super();
if (parameters.schema) { this.fromSchema(parameters.schema);
}
}
/** * Returns default values for all class members * @param memberName String name for a class member * @returns Default value
*/ publicstatic override defaultValues(memberName: typeof VERSION): number; publicstatic override defaultValues(memberName: typeof ENCRYPTED_CONTENT_INFO): EncryptedContentInfo; publicstatic override defaultValues(memberName: typeof UNPROTECTED_ATTRS): Attribute[]; publicstatic override defaultValues(memberName: string): any { switch (memberName) { case VERSION: return0; case ENCRYPTED_CONTENT_INFO: returnnew EncryptedContentInfo(); case UNPROTECTED_ATTRS: return []; default: returnsuper.defaultValues(memberName);
}
}
/** * Compare values with default values for all class members * @param memberName String name for a class member * @param memberValue Value to compare with default value
*/ publicstatic compareWithDefault(memberName: string, memberValue: any): boolean { switch (memberName) { case VERSION: return (memberValue === 0); case ENCRYPTED_CONTENT_INFO: // TODO move to isEmpty method return ((EncryptedContentInfo.compareWithDefault("contentType", memberValue.contentType)) &&
(EncryptedContentInfo.compareWithDefault("contentEncryptionAlgorithm", memberValue.contentEncryptionAlgorithm)) &&
(EncryptedContentInfo.compareWithDefault("encryptedContent", memberValue.encryptedContent))); case UNPROTECTED_ATTRS: return (memberValue.length === 0); default: returnsuper.defaultValues(memberName);
}
}
// Get internal properties from parsed schema this.version = asn1.result.version.valueBlock.valueDec; this.encryptedContentInfo = new EncryptedContentInfo({ schema: asn1.result.encryptedContentInfo }); if (UNPROTECTED_ATTRS in asn1.result) this.unprotectedAttrs = Array.from(asn1.result.unprotectedAttrs, element => new Attribute({ schema: element }));
}
public toSchema(): asn1js.Sequence { //#region Create array for output sequence const outputArray = [];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.