Skip to content
/ eme Public

EME (Encrypt-Mix-Encrypt) wide-block encryption in TypeScript/JavaScript.

License

Notifications You must be signed in to change notification settings

fyears/eme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EME

EME (Encrypt-Mix-Encrypt) wide-block encryption in TypeScript/JavaScript.

Intro

Pure and full TypeScript/JavaScript port of https://github.com/rfjakob/eme.

Almost line-to-line "translation", with all the ported test cases.

Usage

npm install @fyears/eme
import { EMECipher, AESCipherBlock } from "@fyears/eme"
import { deepStrictEqual } from "assert"
import { webcrypto } from "crypto"

(async function(){
    const key = new Uint8Array([
        0,1,2,3,4,5,6,7,
        8,9,10,11,12,13,14,15
    ]) // 16-byte Uint8Array the user provided for the AES part

    const tweak = new Uint8Array(16)
    webcrypto.getRandomValues(tweak)  // iv

    const input = new Uint8Array(64) // some Uint8Array the user provided
    webcrypto.getRandomValues(input)

    const bc = new AESCipherBlock(key)
    const eme = new EMECipher(bc)

    const output = await eme.encrypt(tweak, input)
    const inputBack = await eme.decrypt(tweak, output)

    deepStrictEqual(inputBack, input)
})()

About

EME (Encrypt-Mix-Encrypt) wide-block encryption in TypeScript/JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published