Giter VIP home page Giter VIP logo

aes-ccm's Introduction

Build Status

aes-ccm

AES CCM module using OpenSSL

Installation

npm install aes-ccm --save

encrypt

const ccm = require('aes-ccm');

const key = Buffer.from('404142434445464748494a4b4c4d4e4f', 'hex');
const iv = Buffer.from('101112131415161718191a1b', 'hex');
const plain = Buffer.from('Secret message!', 'utf8');
const aad = Buffer.from('000102030405060708090a0b0c0d0e0f10111213', 'hex');
const tagLength = 16;

const res = ccm.encrypt(key, iv, plain, aad, tagLength);

console.log('ciphertext: ' + res.ciphertext.toString('hex'));
console.log('tag: ' + res.auth_tag.toString('hex'));

decrypt

const ccm = require('aes-ccm');

const key = Buffer.from('404142434445464748494a4b4c4d4e4f', 'hex');
const iv = Buffer.from('101112131415161718191a1b', 'hex');
const aad = Buffer.from('000102030405060708090a0b0c0d0e0f10111213', 'hex');
const ciphertext = Buffer.from('90f640f8b4e61c30d646b3a686dfe8', 'hex');
const tag = Buffer.from('d159ba0b957a1adc9b798cd9cb0d45c1', 'hex');

const dres = ccm.decrypt(key, iv, ciphertext, aad, tag);

console.log('ok: ' + dres.auth_ok);
console.log('plaintext: ' + dres.plaintext.toString('utf8'));

References

Copied from node-aes-ccm.

aes-ccm's People

Contributors

brycekahle avatar erdtman avatar johannespfeiffer avatar raziel057 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

aes-ccm's Issues

node-pre-gyp support

Hi,

any chance of adding support for node-pre-gyp and provide pre-build binaries? see https://www.npmjs.com/package/node-pre-gyp
E.g. when using this npm inside of a docker-container it requires us to provide a full (temp.) build-chain. It also has some complications during development with docker e.g. when mounting node_modules from a different host platform etc.

Kind regards
Joe

Deprication warnings with node 10

build-linux-node-10_1 | CXX(target) Release/obj.target/aes_ccm/lib/aes-ccm.o
build-linux-node-10_1 | ../lib/aes-ccm.cc: In function 'void node_aes_ccm::CcmEncrypt(const v8::FunctionCallbackInfov8::Value&)':
build-linux-node-10_1 | ../lib/aes-ccm.cc:69:43: warning: 'double v8::Value::NumberValue() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
build-linux-node-10_1 | int auth_tag_len = args[4]->NumberValue();
build-linux-node-10_1 | ^
build-linux-node-10_1 | In file included from /root/.node-gyp/10.14.1/include/node/v8.h:26:0,
build-linux-node-10_1 | from /root/.node-gyp/10.14.1/include/node/node.h:63,
build-linux-node-10_1 | from ../lib/aes-ccm.cc:1:
build-linux-node-10_1 | /root/.node-gyp/10.14.1/include/node/v8.h:2475:45: note: declared here
build-linux-node-10_1 | V8_DEPRECATED("Use maybe version", double NumberValue() const);
build-linux-node-10_1 | ^
build-linux-node-10_1 | /root/.node-gyp/10.14.1/include/node/v8config.h:324:3: note: in definition of macro 'V8_DEPRECATED'
build-linux-node-10_1 | declarator attribute((deprecated(message)))
build-linux-node-10_1 | ^~~~~~~~~~
build-linux-node-10_1 | SOLINK_MODULE(target) Release/obj.target/aes_ccm.node
build-linux-node-10_1 | COPY Release/aes_ccm.node
build-linux-node-10_1 | make: Leaving directory '/opt/aes-ccm/build'

Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory

I got this error:

internal/modules/cjs/loader.js:1025
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1025:18)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/plehner/Workspace/git/ng-hex2img/node_modules/aes-ccm/lib/index.js:5:18)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)

With the example code. Did I miss something? aes_ccm.node is in the ..../build/Release folder.

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.