Home Reference Source
public class | source

Crypto

Class providing static crypto primitives.

Static Method Summary

Static Public Methods
public static

Helper function for crypto engine createSigner: returns a signer that uses a key pair.

public static

Helper function for crypto engine createVerifier: returns a signer that uses a key pair.

public static

generateKeys(keyLevel: string, expirationMs: number): Object

Generates a key pair to use with the Token system.

public static

sign(message: string, keys: Object): string

Signs a string and returns the signature.

public static

signJson(json: Object, keys: Object): string

Signs a json object and returns the signature

public static

verify(message: string, signature: string, publicKey: Uint8Array)

Verifies a signature on a string.

public static

verifyJson(json: Object, signature: string, publicKey: Uint8Array)

Verifies a signature on a JSON object.

Static Public Methods

public static createSignerFromKeyPair(keyPair: Object): Object source

Helper function for crypto engine createSigner: returns a signer that uses a key pair.

Params:

NameTypeAttributeDescription
keyPair Object

such as returned by Token.Crypto.generateKeys

Return:

Object

signer object

public static createVerifierFromKeyPair(keyPair: Object): Object source

Helper function for crypto engine createVerifier: returns a signer that uses a key pair.

Params:

NameTypeAttributeDescription
keyPair Object

such as returned by Token.Crypto.generateKeys, only public key

Return:

Object

verifier object

public static generateKeys(keyLevel: string, expirationMs: number): Object source

Generates a key pair to use with the Token system.

Params:

NameTypeAttributeDescription
keyLevel string

'LOW', 'STANDARD', or 'PRIVILEGED'

expirationMs number

(optional) expiration duration of the key in milliseconds

Return:

Object

generated key pair

public static sign(message: string, keys: Object): string source

Signs a string and returns the signature.

Params:

NameTypeAttributeDescription
message string

message to sign

keys Object

keys to sign with

Return:

string

signature

public static signJson(json: Object, keys: Object): string source

Signs a json object and returns the signature

Params:

NameTypeAttributeDescription
json Object

object to sign

keys Object

keys to sign with

Return:

string

signature

public static verify(message: string, signature: string, publicKey: Uint8Array) source

Verifies a signature on a string. Throws if verification fails.

Params:

NameTypeAttributeDescription
message string

string to verify

signature string

signature to verify

publicKey Uint8Array

public key to use for verification

public static verifyJson(json: Object, signature: string, publicKey: Uint8Array) source

Verifies a signature on a JSON object. Throws if verification fails.

Params:

NameTypeAttributeDescription
json Object

JSON object to verify

signature string

signature to verify

publicKey Uint8Array

public key to use for verification