vncore / com.venuenext.vncore.security / Crypto

Crypto

object Crypto

Crypto VenueNext

Created on 2/27/19. Copyright © 2019 VenueNext Inc. All rights reserved.

Types

Ciphertext

class Ciphertext

Properties

secureRandom

Uses SecureRandom to generate keys

val secureRandom: SecureRandom

Functions

checkHmac

Checks the HMAC for the given data and the given key to match the expectedHmac.

fun checkHmac(data: ByteArray, key: ByteArray, expectedHmac: ByteArray): Boolean

createHmac

Generates a HMAC for the given data with the given key using HMAC-SHA256.

fun createHmac(data: ByteArray, key: ByteArray): ByteArray

decryptCbc

Decrypts the given ciphertext using the given key under AES CBC with PKCS5 padding.

fun decryptCbc(ciphertext: Ciphertext, key: ByteArray): ByteArray

decryptGcm

Decrypts the given ciphertext using the given key under AES GCM.

fun decryptGcm(ciphertext: Ciphertext, key: ByteArray): ByteArray

encryptCbc

Encrypts the given plaintext with the given key under AES CBC with PKCS5 padding.

fun encryptCbc(plaintext: ByteArray, key: ByteArray): Ciphertext

encryptGcm

Encrypts the given plaintext with the given key under AES GCM.

fun encryptGcm(plaintext: ByteArray, key: ByteArray): Ciphertext

generateIv

Generates an IV. The IV is always 128 bit long.

fun generateIv(): ByteArray

generateKey

Generates a key with sizeInBits bits.

fun generateKey(sizeInBits: Int): ByteArray

generateNonce

Generates a nonce for GCM mode. The nonce is always 96 bit long.

fun generateNonce(): ByteArray