Giter VIP home page Giter VIP logo

privmx-crypto-js's Introduction

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

privmx-crypto-js's People

Contributors

ldudzsim avatar mattmoosh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.