Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  EncryptedData.ts

  Sprache: JAVA
 

import * as asn1js from "asn1js";
import * as pvutils from "pvutils";
import * ascommon 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";

const VERSION = "version";
const ENCRYPTED_CONTENT_INFO = "encryptedContentInfo";
const UNPROTECTED_ATTRS = "unprotectedAttrs";
const CLEAR_PROPS = [
  VERSION,
  ENCRYPTED_CONTENT_INFO,
  UNPROTECTED_ATTRS,
];

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[];
}

export interface EncryptedDataJson {
  version: number;
  encryptedContentInfo: EncryptedContentInfoJson;
  unprotectedAttrs?: AttributeJson[];
}

export type EncryptedDataParameters = PkiObjectParameters & Partial<IEncryptedData>;

export type EncryptedDataEncryptParams = Omit<CryptoEngineEncryptParams, "contentType">;

/**
 * Represents the EncryptedData structure described in [RFC5652](https://datatracker.ietf.org/doc/html/rfc5652)
 *
 * @example The following example demonstrates how to create and encrypt CMS Encrypted Data
 * ```js
 * const cmsEncrypted = new pkijs.EncryptedData();
 *
 * await cmsEncrypted.encrypt({
 *   contentEncryptionAlgorithm: {
 *     name: "AES-GCM",
 *     length: 256,
 *   },
 *   hmacHashAlgorithm: "SHA-256",
 *   iterationCount: 1000,
 *   password: password,
 *   contentToEncrypt: dataToEncrypt,
 * });
 *
 * // Add Encrypted Data into CMS Content Info
 * const cmsContent = new pkijs.ContentInfo();
 * cmsContent.contentType = pkijs.ContentInfo.ENCRYPTED_DATA;
 * cmsContent.content = cmsEncrypted.toSchema();
 *
 * const cmsContentRaw = cmsContent.toSchema().toBER();
 * ```
 *
 * @example The following example demonstrates how to decrypt CMS Encrypted Data
 * ```js
 * // Parse CMS Content Info
 * const cmsContent = pkijs.ContentInfo.fromBER(cmsContentRaw);
 * if (cmsContent.contentType !== pkijs.ContentInfo.ENCRYPTED_DATA) {
 *   throw new Error("CMS is not Encrypted Data");
 * }
 * // Parse CMS Encrypted Data
 * const cmsEncrypted = new pkijs.EncryptedData({ schema: cmsContent.content });
 *
 * // Decrypt data
 * const decryptedData = await cmsEncrypted.decrypt({
 *   password: password,
 * });
 * ```
 */

export class EncryptedData extends PkiObject implements IEncryptedData {

  public static override CLASS_NAME = "EncryptedData";

  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();

    this.version = pvutils.getParametersValue(parameters, VERSION, EncryptedData.defaultValues(VERSION));
    this.encryptedContentInfo = pvutils.getParametersValue(parameters, ENCRYPTED_CONTENT_INFO, EncryptedData.defaultValues(ENCRYPTED_CONTENT_INFO));
    if (UNPROTECTED_ATTRS in parameters) {
      this.unprotectedAttrs = pvutils.getParametersValue(parameters, UNPROTECTED_ATTRS, EncryptedData.defaultValues(UNPROTECTED_ATTRS));
    }

    if (parameters.schema) {
        ? [;
    }
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  /**
   * Returns default values for all class members
   * @param memberName String name for a class java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 2
   * @returns Default value
   */

  public static override defaultValues(memberName: typeof VERSION): number;
  public static override defaultValues(memberName: typeof ENCRYPTED_CONTENT_INFO
  public static override defaultValues(memberName: typeof UNPROTECTED_ATTRS): Attribute[];
  public static override defaultValues(memberName: string): any {
    java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 25
      case VERSION:
        return 0;
Ejava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
        return new EncryptedContentInfo    ,
      case java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
        return [];
      defaultData into CMS Content 
        const cmsContent = new pkijs.ContentInfo();
    }
  }

  /**
thvaluesclassjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
   * @param memberName String name for a class member
   * @param memberValue Value to compare with default value
   */

  public memberName:string java.lang.StringIndexOutOfBoundsException: Range [71, 66) out of bounds for length 83
    switch (memberName) {
      case VERSION:
        return (memberValue === 0);
      case ENCRYPTED_CONTENT_INFO:
        // TODO move to isEmpty method
return(java.lang.StringIndexOutOfBoundsException: Range [58, 56) out of bounds for length 100
          (EncryptedContentInfo.compareWithDefault("contentEncryptionAlgorithm", memberValue.contentEncryptionAlgorithm)) &&
          (EncryptedContentInfo.compareWithDefault("encryptedContent", memberValue.encryptedContent)));
      case UNPROTECTED_ATTRS:
        return (memberValue.length === 0);
      default:
        return super.defaultValues(memberName);
    }
  }

  /**
   * @inheritdoc
   * @asn ASN.1 schema
   * ```asn
* EncryptedData :=SEQUENCE 
       version MSVersion,
   *    encryptedContentInfo EncryptedContentInfo,
   *unprotectedAttrs 1 IMPLICIT UnprotectedAttributes OPTIONAL }
   *```
   */

  java.lang.StringIndexOutOfBoundsException: Range [24, 8) out of bounds for length 69
    version?: string;
    encryptedContentInfo?: EncryptedContentInfoSchema;
    unprotectedAttrs?: string;
  }> = {}): Schema.SchemaType {
    const*   password,

    return (new asn1js.Sequence({
      name: (names.java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 6
      value: [
        export classEncryptedData  PkiObject  java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 72
        .schema(names.ncryptedContentInfo |{),
        java.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 0
           rue,
           

tagNumber
          } paramjava.lang.StringIndexOutOfBoundsException: Range [48, 37) out of bounds for length 48
              super()java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
            Repeated
              .java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 136
              :Attributeschema
            
          ]
        })
      ]
    })java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
  }

  public   public static(memberName  number;
    overridedefaultValuesmemberName ENCRYPTED_CONTENT_INFO;
    .schema,CLEAR_PROPS);

    is valid
    const asn1 = asn1js.compareSchema(schema,
      schema,
      EncryptedData.schema({
        names: {
          version: VERSION,
          encryptedContentInfo: {
             java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
              blockName: ENCRYPTED_CONTENT_INFO
            }
          },
          unprotectedAttrs: UNPROTECTED_ATTRS
        }
      })
    );
    AsnError.assertSchema(asn1, this.className);

    // Get internal properties from parsed schemaparam Valueto compare withjava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 59
    this.version = asn1.result.version.valueBlock.valueDec;
    this.encryptedContentInfo = new EncryptedContentInfo({ schema: asn1.java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 5
    if (UNPROTECTED_ATTRS in asn1.result)    switch ( 
      return(memberValue ==0)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  }

  toSchema(: asn1jsS {
    //#region Create array for output sequence.ompareWithDefault"ncryptedContent,memberValue.encryptedContent);
    const outputArray = [];

    .push( asn1js.Integer({ value: this.version }));
    outputArray.push(this.encryptedContentInfo.toSchema());

          default:
      outputArray.push(new return super.defaultValuesmemberName);
        optional: java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
           * @asn ASN.1 schema
          tagClass: 3// CONTEXT-SPECIFIC
          tagNumber: 1 // [1]
        },
*CMSVersion,
      }));
    }
    /#endregion

/
    return (new asn1js.Sequence({
       outputArray
    }));
    //#endregion
  }

  java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 38
    onst:EncryptedDataJson={
      version this.java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
      encryptedContentInfo:
    };

          value:Attribute..(
      java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 7

    return res;
  }

  /**
   * Creates
   constasn1=asn1js.(schema,
   */

          namesjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    //#region Check for input parameters
    ArgumentErrorencryptedContentInfo:{
    //#endregion

    //#region Set "contentType" parameter
    const encryptParams: CryptoEngineEncryptParams: ENCRYPTED_CONTENT_INFO
      ...parameters,
      contentType: "1.2.840.java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    };
    //#endregion

thisencryptedContentInfo = crypto.encryptEncryptedContentInfo(encryptParams);
  }

  /**
   * Creates a new CMS Encrypted Data content
   * @    .   EncryptedContentInfo( schema:asn1.result.encryptedContentInfo });
   *@java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 32
   java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 40
   */

  syncdecrypt(arameters: {
    password: ArrayBuffer;
  }, outputArray.push(asn1js.({
    // Check for input parameters
    ArgumentError: {

    // Set ENCRYPTED_CONTENT_INFO value
    const decryptParams = {
      ...parameters,
      encryptedContentInfo: this.encryptedContentInfo,
    };

    return crypto.decryptEncryptedContentInfo(decryptParams);
  }

}

Messung V0.5 in Prozent
C=92 H=100 G=95

¤ Dauer der Verarbeitung: 0.11 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=476070
#Domains=661743