Home Reference Source Test
public class | source

Crypto

Class with the cryptographic functions for the authentication protocol

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

concatPMSwithRandoms(pms: *, toRandom: *, fromRandom: *): *

public

decode(value: string): byteArray

decode a base64 value in a new Uint8Array

public

decryptAES(key: *, data: *, iv: *): *

public

decryptRSA(privKey: *, data: *): *

public

encode(value: byteArray): string

encode a byteArray value in base 64 encode

public

encryptAES(key: *, data: *, iv: *): *

public

encryptRSA(pubKey: *, data: *): *

public

generateIV(): byteArray

Generates a 128 bit random value.

public

generateKeys(secret: byteArray, data: String): Array<byteArray>

generates both users MAC and encryption keys.

public

generateMasterSecret(hmacKey: *, data: *): byteArray

generates a masterKey secret (PMS) of 48 bytes (384 bits) using the premaster secret and two randoms

public

generatePMS(): byteArray

generates a premaster secret (PMS) of 48 bytes (384 bits) randomly

public

generates a RSA public/private key pair with a modulus length of 2048 bits

public

generateRandom(): byteArray

Generates a 256 bit random value.

public

hashHMAC(key: byteArray, data: string): byteArray

creates a hash using the HMAC algorithm

public

signRSA(privKey: *, data: *): *

public

verifyHMAC(key: byteArray, data: string, signature: byteArray): boolean

verifies an hash using the HMAC algorithm

public

verifyRSA(pubKey: *, data: *, signature: *): *

Public Constructors

public constructor() source

Public Methods

public concatPMSwithRandoms(pms: *, toRandom: *, fromRandom: *): * source

Params:

NameTypeAttributeDescription
pms *
toRandom *
fromRandom *

Return:

*

public decode(value: string): byteArray source

decode a base64 value in a new Uint8Array

Params:

NameTypeAttributeDescription
value string

value encoded in base 64

Return:

byteArray

decodedValue

public decryptAES(key: *, data: *, iv: *): * source

Params:

NameTypeAttributeDescription
key *
data *
iv *

Return:

*

public decryptRSA(privKey: *, data: *): * source

Params:

NameTypeAttributeDescription
privKey *
data *

Return:

*

public encode(value: byteArray): string source

encode a byteArray value in base 64 encode

Params:

NameTypeAttributeDescription
value byteArray

byteArray value

Return:

string

encoded value

public encryptAES(key: *, data: *, iv: *): * source

Params:

NameTypeAttributeDescription
key *
data *
iv *

Return:

*

public encryptRSA(pubKey: *, data: *): * source

Params:

NameTypeAttributeDescription
pubKey *
data *

Return:

*

public generateIV(): byteArray source

Generates a 128 bit random value.

Return:

byteArray

array random value

public generateKeys(secret: byteArray, data: String): Array<byteArray> source

generates both users MAC and encryption keys. generate as output an array with 4 byteArray each with 32 bytes

Params:

NameTypeAttributeDescription
secret byteArray

secret to be used in the HMAC function

data String

information to be used as seed

Return:

Array<byteArray>

key array with the information to generate keys

public generateMasterSecret(hmacKey: *, data: *): byteArray source

generates a masterKey secret (PMS) of 48 bytes (384 bits) using the premaster secret and two randoms

Params:

NameTypeAttributeDescription
hmacKey *
data *

Return:

byteArray

array master secret key with 48 bytes

public generatePMS(): byteArray source

generates a premaster secret (PMS) of 48 bytes (384 bits) randomly

Return:

byteArray

array premaster secret key

public generateRSAKeyPair(): JSON source

generates a RSA public/private key pair with a modulus length of 2048 bits

Return:

JSON

keyPair json containing the public and private keys

public generateRandom(): byteArray source

Generates a 256 bit random value. 32 bits are extrated from the machine time, the remaining are generated randomly

Return:

byteArray

array random value

public hashHMAC(key: byteArray, data: string): byteArray source

creates a hash using the HMAC algorithm

Params:

NameTypeAttributeDescription
key byteArray

key to be used in the hmac

data string

information to be hashed

Return:

byteArray

signature resulting hash

public signRSA(privKey: *, data: *): * source

Params:

NameTypeAttributeDescription
privKey *
data *

Return:

*

public verifyHMAC(key: byteArray, data: string, signature: byteArray): boolean source

verifies an hash using the HMAC algorithm

Params:

NameTypeAttributeDescription
key byteArray

key to be used in the hmac

data string

information to be hashed to compare

signature byteArray

hash to compare with the received data

Return:

boolean

isvalid boolean saying if the data corresponds to the hash received

public verifyRSA(pubKey: *, data: *, signature: *): * source

Params:

NameTypeAttributeDescription
pubKey *
data *
signature *

Return:

*