How to use the @peculiar/asn1-schema.AsnPropTypes.Integer 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 / asn / rsa_private_key.ts View on Github external
// RSAPrivateKey ::= SEQUENCE {
//   version           Version,
//   modulus           INTEGER,  -- n
//   publicExponent    INTEGER,  -- e
//   privateExponent   INTEGER,  -- d
//   prime1            INTEGER,  -- p
//   prime2            INTEGER,  -- q
//   exponent1         INTEGER,  -- d mod (p-1)
//   exponent2         INTEGER,  -- d mod (q-1)
//   coefficient       INTEGER,  -- (inverse of q) mod p
//   otherPrimeInfos   OtherPrimeInfos OPTIONAL
// }

export class RsaPrivateKey {

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerConverter })
  public version = 0;

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "n", converter: JsonBase64UrlArrayBufferConverter })
  public modulus = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter })
  public publicExponent = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "d", converter: JsonBase64UrlArrayBufferConverter })
  public privateExponent = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "p", converter: JsonBase64UrlArrayBufferConverter })
github PeculiarVentures / webcrypto / src / asn / rsa_public_key.ts View on Github external
// RFC 3437
// https://tools.ietf.org/html/rfc3447#appendix-A.1.1
//
// RSAPublicKey ::= SEQUENCE {
//   modulus           INTEGER,  -- n
//   publicExponent    INTEGER,  -- e
// }

export class RsaPublicKey {

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "n", converter: JsonBase64UrlArrayBufferConverter })
  public modulus = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter })
  public publicExponent = new ArrayBuffer(0);

}
github PeculiarVentures / webcrypto / src / asn / rsa_public_key.ts View on Github external
import { AsnProp, AsnPropTypes } from "@peculiar/asn1-schema";
import { JsonProp } from "@peculiar/json-schema";
import { AsnIntegerArrayBufferConverter, JsonBase64UrlArrayBufferConverter } from "../converters";

// RFC 3437
// https://tools.ietf.org/html/rfc3447#appendix-A.1.1
//
// RSAPublicKey ::= SEQUENCE {
//   modulus           INTEGER,  -- n
//   publicExponent    INTEGER,  -- e
// }

export class RsaPublicKey {

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "n", converter: JsonBase64UrlArrayBufferConverter })
  public modulus = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter })
  public publicExponent = new ArrayBuffer(0);

}
github PeculiarVentures / webcrypto / src / asn / ec_signature.ts View on Github external
const bytes = new Uint8Array(value);
    if (bytes[0] > 127) {
      const newValue = new Uint8Array(bytes.length + 1);
      newValue.set(bytes, 1);
      return new asn1.Integer({ valueHex: newValue });
    }
    return new asn1.Integer({ valueHex: value });
  },
};

export class EcDsaSignature {

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter })
  public r = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter })
  public s = new ArrayBuffer(0);

}
github PeculiarVentures / webcrypto / src / asn / rsa_private_key.ts View on Github external
@JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter })
  public publicExponent = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "d", converter: JsonBase64UrlArrayBufferConverter })
  public privateExponent = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "p", converter: JsonBase64UrlArrayBufferConverter })
  public prime1 = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "q", converter: JsonBase64UrlArrayBufferConverter })
  public prime2 = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "dp", converter: JsonBase64UrlArrayBufferConverter })
  public exponent1 = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "dq", converter: JsonBase64UrlArrayBufferConverter })
  public exponent2 = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
  @JsonProp({ name: "qi", converter: JsonBase64UrlArrayBufferConverter })
  public coefficient = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Any, optional: true })
  public otherPrimeInfos?: ArrayBuffer;

}
github PeculiarVentures / webcrypto / src / asn / ec_signature.ts View on Github external
: bytes.buffer;
  },
  toASN: (value: ArrayBuffer) => {
    const bytes = new Uint8Array(value);
    if (bytes[0] > 127) {
      const newValue = new Uint8Array(bytes.length + 1);
      newValue.set(bytes, 1);
      return new asn1.Integer({ valueHex: newValue });
    }
    return new asn1.Integer({ valueHex: value });
  },
};

export class EcDsaSignature {

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter })
  public r = new ArrayBuffer(0);

  @AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter })
  public s = new ArrayBuffer(0);

}

@peculiar/asn1-schema

Decorators for ASN.1 schemas building

MIT
Latest version published 5 months ago

Package Health Score

71 / 100
Full package analysis