How to use the pkijs.ECPublicKey function in pkijs

To help you get started, we’ve selected a few pkijs 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 / node-webcrypto-p11 / src / mechs / ec / crypto.ts View on Github external
crvName = "K-256";
        break;
      case "1.2.840.10045.3.1.7": // P-256
        crvName = "P-256";
        break;
      case "1.3.132.0.34": // P-384
        crvName = "P-384";
        break;
      case "1.3.132.0.35": // P-521
        crvName = "P-521";
        break;
      default:
        throw new Error(`Unsupported EC named curve '${crvName}'`);
    }

    const parsedKey = new pkijs.ECPublicKey({
      namedCurve: algId === "1.3.132.0.10" ? "1.2.840.10045.3.1.7" : algId,
      schema: spki.subjectPublicKey.valueBlock.valueHex,
    });

    return {
      kty: "EC",
      crv: crvName,
      x: Convert.ToBase64Url(parsedKey.x),
      y: Convert.ToBase64Url(parsedKey.y),
    };
  }
github PeculiarVentures / node-webcrypto-p11 / lib / crypto / ec.ts View on Github external
crvName = "K-256";
            break;
        case "1.2.840.10045.3.1.7": // P-256
            crvName = "P-256";
            break;
        case "1.3.132.0.34": // P-384
            crvName = "P-384";
            break;
        case "1.3.132.0.35": // P-521
            crvName = "P-521";
            break;
        default:
            throw new Error(`Unsupported EC named curve '${crvName}'`);
    }

    const parsedKey = new ECPublicKey({
        namedCurve: algId === "1.3.132.0.10" ? "1.2.840.10045.3.1.7" : algId,
        schema: spki.subjectPublicKey.valueBlock.valueHex,
    });

    return {
        kty: "EC",
        crv: crvName,
        x: Base64Url.encode(new Uint8Array(parsedKey.x)),
        y: Base64Url.encode(new Uint8Array(parsedKey.y)),
    };
}
github PeculiarVentures / node-webcrypto-p11 / src / mechs / ec / crypto.ts View on Github external
protected static jwk2spki(jwk: JsonWebKey) {
    const parsedKey = new pkijs.ECPublicKey();
    let coordinateLength = 0;

    if ("crv" in jwk) {
      switch (jwk.crv.toUpperCase()) {
        case "K-256":
          parsedKey.namedCurve = "1.3.132.0.10";
          coordinateLength = 32;
          break;
        case "P-256":
          parsedKey.namedCurve = "1.2.840.10045.3.1.7";
          coordinateLength = 32;
          break;
        case "P-384":
          parsedKey.namedCurve = "1.3.132.0.34";
          coordinateLength = 48;
          break;
github PeculiarVentures / node-webcrypto-p11 / lib / crypto / ec.ts View on Github external
function jwk2spki(jwk: JsonWebKey) {
    const parsedKey = new ECPublicKey();
    let coordinateLength = 0;

    if ("crv" in jwk) {
        switch (jwk.crv.toUpperCase()) {
            case "K-256":
                parsedKey.namedCurve = "1.3.132.0.10";
                coordinateLength = 32;
                break;
            case "P-256":
                parsedKey.namedCurve = "1.2.840.10045.3.1.7";
                coordinateLength = 32;
                break;
            case "P-384":
                parsedKey.namedCurve = "1.3.132.0.34";
                coordinateLength = 48;
                break;

pkijs

Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it p

BSD-3-Clause
Latest version published 5 days ago

Package Health Score

81 / 100
Full package analysis