interface CCFCrypto {
    digest(algorithm, plaintext): ArrayBuffer;
    eddsaJwkToPem(jwk): string;
    eddsaPemToJwk(pem, kid?): JsonWebKeyEdDSAPrivate;
    generateAesKey(size): ArrayBuffer;
    generateEcdsaKeyPair(curve): CryptoKeyPair;
    generateEddsaKeyPair(curve): CryptoKeyPair;
    generateRsaKeyPair(size, exponent?): CryptoKeyPair;
    isValidX509CertBundle(pem): boolean;
    isValidX509CertChain(chain, trusted): boolean;
    jwkToPem(jwk): string;
    pemToJwk(pem, kid?): JsonWebKeyECPrivate;
    pubEddsaJwkToPem(jwk): string;
    pubEddsaPemToJwk(pem, kid?): JsonWebKeyEdDSAPublic;
    pubJwkToPem(jwk): string;
    pubPemToJwk(pem, kid?): JsonWebKeyECPublic;
    pubRsaJwkToPem(jwk): string;
    pubRsaPemToJwk(pem, kid?): JsonWebKeyRSAPublic;
    rsaJwkToPem(jwk): string;
    rsaPemToJwk(pem, kid?): JsonWebKeyRSAPrivate;
    sign(algorithm, key, plaintext): ArrayBuffer;
    unwrapKey(key, wrappingKey, wrapAlgo): ArrayBuffer;
    verifySignature(algorithm, key, signature, plaintext): boolean;
    wrapKey(key, wrappingKey, wrapAlgo): ArrayBuffer;
}

Methods

  • Generate a digest (hash) of the given data.

    Parameters

    Returns ArrayBuffer

  • Converts an EdDSA private key as JSON Web Key (JWK) object to PEM. Currently only Curve25519 is supported.

    Parameters

    Returns string

  • Converts an EdDSA private key as PEM to JSON Web Key (JWK) object. Only Curve25519 and X25519 are supported.

    Parameters

    • pem: string

      EdDSA private key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyEdDSAPrivate

  • Generate an AES key.

    Parameters

    • size: number

      The length in bits of the key to generate. 128, 192, or 256.

    Returns ArrayBuffer

  • Generate an ECDSA key pair.

    Parameters

    • curve: string

      The name of the curve, one of "secp256r1", "secp256k1", "secp384r1".

    Returns CryptoKeyPair

  • Generate an EdDSA key pair.

    Parameters

    • curve: string

      The name of the curve. Only "curve25519" and "x25519" are supported.

    Returns CryptoKeyPair

  • Generate an RSA key pair.

    Parameters

    • size: number

      The length in bits of the RSA modulus. Minimum: 2048.

    • Optional exponent: number

      The public exponent. Default: 65537.

    Returns CryptoKeyPair

  • Returns whether a string is a PEM-encoded bundle of X.509 certificates.

    A bundle consists of one or more certificates. Certificates in the bundle do not have to be related to each other. Validation is only syntactical, properties like validity dates are not evaluated.

    Parameters

    • pem: string

    Returns boolean

  • Returns whether a certificate chain is valid given a set of trusted certificates. The chain and trusted certificates are PEM-encoded bundles of X.509 certificates.

    Parameters

    • chain: string
    • trusted: string

    Returns boolean

  • Converts an elliptic curve private key as JSON Web Key (JWK) object to PEM.

    Parameters

    Returns string

  • Converts an elliptic curve private key as PEM to JSON Web Key (JWK) object.

    Parameters

    • pem: string

      Elliptic curve private key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyECPrivate

  • Converts an EdDSA public key as JSON Web Key (JWK) object to PEM. Currently only Curve25519 is supported.

    Parameters

    Returns string

  • Converts an EdDSA public key as PEM to JSON Web Key (JWK) object. Only Curve25519 and X25519 are supported.

    Parameters

    • pem: string

      EdDSA public key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyEdDSAPublic

  • Converts an elliptic curve public key as JSON Web Key (JWK) object to PEM.

    Parameters

    Returns string

  • Converts an elliptic curve public key as PEM to JSON Web Key (JWK) object.

    Parameters

    • pem: string

      Elliptic curve public key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyECPublic

  • Converts an RSA public key as JSON Web Key (JWK) object to PEM.

    Parameters

    Returns string

  • Converts an RSA public key as PEM to JSON Web Key (JWK) object.

    Parameters

    • pem: string

      RSA public key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyRSAPublic

  • Converts an RSA private key as JSON Web Key (JWK) object to PEM.

    Parameters

    Returns string

  • Converts an RSA private key as PEM to JSON Web Key (JWK) object.

    Parameters

    • pem: string

      RSA private key as PEM

    • Optional kid: string

      Key identifier (optional)

    Returns JsonWebKeyRSAPrivate

  • Generate a signature.

    Parameters

    • algorithm: SigningAlgorithm

      Signing algorithm and parameters

    • key: string

      A PEM-encoded private key

    • plaintext: ArrayBuffer

      Input data that will be signed

    Returns ArrayBuffer

    Throws

    Will throw an error if the key is not compatible with the signing algorithm or if an unknown algorithm is used.

  • Unwraps a key using a wrapping key.

    Constraints on the key and wrappingKey parameters depend on the wrapping algorithm that is used (wrapAlgo).

    Parameters

    Returns ArrayBuffer

  • Returns whether digital signature is valid.

    Parameters

    • algorithm: SigningAlgorithm

      Signing algorithm and parameters

    • key: string

      A PEM-encoded public key or X.509 certificate

    • signature: ArrayBuffer

      Signature to verify

    • plaintext: ArrayBuffer

      Input data that was signed

    Returns boolean

    Throws

    Will throw an error if the key is not compatible with the signing algorithm or if an unknown algorithm is used.

  • Wraps a key using a wrapping key.

    Constraints on the key and wrappingKey parameters depend on the wrapping algorithm that is used (wrapAlgo).

    Parameters

    Returns ArrayBuffer

Generated using TypeDoc