Skip to content

simplito/privmx-crypto-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrivMX Crypto Java Script ....

Information

...

Keywords: Hash HMAC AES XTEA RSA KeyDerivation ECC BIP39 SRP Random ...

This software is licensed under the MIT License.

Projects which use the library: PrivMX WebMail, ...

Installation

...

Implementation details

...

API description

Hash functions

Name Description Params Result
sha1 SHA-1 (20 bytes long) Buffer data Promise<Buffer>
sha256 SHA-256 (32 bytes long) Buffer data Promise<Buffer>
sha512 SHA-512 (64 bytes long) Buffer data Promise<Buffer>

Hmac functions

Name Description Params Result
hmacSha1 HMAC-SHA-1 Buffer key
Buffer data
Promise<Buffer>
hmacSha256 HMAC-SHA-256 Buffer key
Buffer data
Promise<Buffer>
hmacSha512 HMAC-SHA-512 Buffer key
Buffer data
Promise<Buffer>

AES encryption

Name Description Params Result
aes256Ecb AES-256-ECB Buffer data
Buffer key
Promise<Buffer>
aes256EcbDecrypt AES-256-ECB Buffer data
Buffer key
Promise<Buffer>
aes256CbcPcks7Encrypt AES-256-CBC with PKCS7 padding encryption Buffer data
Buffer key
Buffer iv
Promise<Buffer>
aes256CbcPcks7Decrypt AES-256-CBC with PKCS7 padding decryption Buffer data
Buffer key
Buffer iv
Promise<Buffer>
aes256CbcHmac256Encrypt AES-256-CBC with PKCS7 padding and SHA-256 HMAC with NIST compatible KDF Buffer data
Buffer key
bool deterministic, default: false
number taglen, default: 16
Promise<Buffer>
aes256CbcHmac256Decrypt AES-256-CBC with PKCS7 padding and SHA-256 HMAC with NIST compatible KDF Buffer data
Buffer key
number taglen, default: 16
Promise<Buffer>

XTEA encryption

Name Description Params Result
xteaEcbPkcs7Encrypt XTEA-ECB with PKCS7 padding encryption Buffer data
Buffer key
Promise<Buffer>
xteaEcbPkcs7Decrypt XTEA-ECB with PKCS7 padding decryption Buffer data
Buffer key
Promise<Buffer>

RSA encryption

Name Description Params Result
rsaGenerateKey number bits Promise<string>
rsaOaepEncrypt string key
Buffer data
Promise<Buffer>
rsaOaepDecrypt string key
Buffer data
Promise<Buffer>
rsaSign string key
Buffer data
Promise<Buffer>
rsaVerify string key
Buffer signature
Buffer data
Promise<boolean>
encryptPrivateKey string key
string passphrase
Promise<string>
decryptPrivateKey string enckey
string passphrase
Promise<string>

Key derivation

Name Description Params Result
pbkdf2 string password
Buffer salt
number rounds
number length
string algorithm
Promise<Buffer>
prf_tls12 Buffer key
Buffer seed
number length
Promise<Buffer>

ECC functions

Name Description Params Result
signToCompactSignature Ecc.PrivateKey key
Buffer message
Promise<Buffer>
verifyCompactSignature Ecc.PublicKey key
Buffer data
Buffer signature
Promise<bool>
signToCompactSignatureWithHash Ecc.PrivateKey key
Buffer message
Promise<Buffer>
verifyCompactSignatureWithHash Ecc.PublicKey key
Buffer data
Buffer signature
Promise<bool>
getSharedKey Ecc.PrivateKey private
Ecc.PublicKey public
Promise<Buffer>
deriveHardened Ecc.ExtKey key
number index
Promise<Ecc.ExtKey>
eciesEncrypt Ecc.PrivateKey private
Ecc.PublicKey public
Buffer data
Promise<Buffer>
eciesDecrypt Ecc.PrivateKey private
Ecc.PublicKey public
Buffer data
Promise<Buffer>

BIP39 functions

interface Bip39Result {
    entropy: Buffer;
    mnemonic: Buffer;
    extKey: Ecc.ExtKey;
};
Name Description Params Result
bip39Generate number strength
string password
Promise<Bip39Result>
bip39FromEntropy Buffer entropy
string password
Promise<Bip39Result>
bip39FromMnemonic Buffer entropy
string password
Promise<Bip39Result>
bip39GetExtKey Buffer entropy
string password
Promise<Ecc.ExtKey>

SRP functions

interface RegisterResult {
    s: Buffer;
    v: Buffer;
};

interface LoginStep1Result {
    A: Buffer;
    K: Buffer;
    M1: Buffer;
    M2: Buffer;
};
Name Description Params Result
srpRegister Buffer N
Buffer g
string I
string P
Promise<RegisterResult>
srpLoginStep1 Buffer N
Buffer g
Buffer s
Buffer B
Buffer k
string I
string P
Promise<LoginStep1Result>
srpLoginStep2 Buffer clientM2
Buffer serverM2
Promise<void>

Random generation

Name Description Params Result
randomFeed Buffer feed void
randomInt32 void number
randomDouble void number
randomBytes number count Buffer
randomBits number count Buffer
randomBN BN max BN

Misc.

Name Description Params Result
reductKey Reducts 32-bytes long key to 16-bytes long by SHA-256 and takes first 16 bytes Buffer key Promise<Buffer>
generateIv Generates IV from index for AES (16 bytes long) Buffer key
number index
Promise<Buffer>

Build

gulp

Test

Browser tests

npm start

and browse http://localhost:8123/

Mocha tests

npm test

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •