How to use the @peculiar/asn1-schema.AsnSerializer.toASN function in @peculiar/asn1-schema

To help you get started, we’ve selected a few @peculiar/asn1-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / webcrypto / src / mechs / ec / public_key.ts View on Github external
public fromJSON(json: JsonWebKey) {
    const key = JsonParser.fromJSON(json, { targetSchema: asn.EcPublicKey });

    const keyInfo = new asn.PublicKeyInfo();
    keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.10045.2.1";
    keyInfo.publicKeyAlgorithm.parameters = AsnSerializer.serialize(
      new ObjectIdentifier(getOidByNamedCurve(json.crv!)),
    );
    keyInfo.publicKey = AsnSerializer.toASN(key).valueHex;

    this.data = Buffer.from(AsnSerializer.serialize(keyInfo));

    return this;
  }
}

@peculiar/asn1-schema

Decorators for ASN.1 schemas building

MIT
Latest version published 7 months ago

Package Health Score

71 / 100
Full package analysis