@microsoft/ccf-app
    Preparing search index...

    Interface CCFCrypto

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

    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

      • Optionalkid: 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", "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.

      • Optionalexponent: 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

      • Optionalkid: 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

      • Optionalkid: 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

      • Optionalkid: 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

      • Optionalkid: 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

      • Optionalkid: 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

      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

      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