Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@particle/device-control-crypto

Package Overview
Dependencies
Maintainers
29
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@particle/device-control-crypto

Elliptic Curve J-PAKE and AES CCM for Node.js and browsers

  • 1.1.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
29
Created
Source

@particle/device-control-crypto

Elliptic Curve J-PAKE and AES CCM for Node.js and browsers.

Installation

npm install @particle/device-control-crypto --save

API

Ccm

A class implementing the CCM mode of operation for a block cipher.

Kind: global class


new Ccm(options)

Constructor.

ParamTypeDefaultDescription
optionsObjectOptions.
options.encryptEncryptFunctionEncryption function.
options.nonceLengthNumberNonce length in bytes. The value must be in the range [7, 13].
[options.tagLength]Number16Length of the authentication tag in bytes: 4, 6, 8, 10, 12, 14 or 16.

ccm.encrypt(data, nonce, [addData]) ⇒ Promise.<Uint8Array>

Encrypt a message.

Kind: instance method of Ccm
Returns: Promise.<Uint8Array> - Encrypted data. The authentication tag is appended to the encrypted data.

ParamTypeDescription
dataUint8ArrayData to encrypt.
nonceUint8ArrayNonce.
[addData]Uint8ArrayAdditional authenticated data.

ccm.decrypt(data, nonce, [addData]) ⇒ Promise.<Uint8Array>

Decrypt a message.

Kind: instance method of Ccm
Returns: Promise.<Uint8Array> - Decrypted data.
Throws:

  • Throws an error if decryption fails.
ParamTypeDescription
dataUint8ArrayData to decrypt. The authentication tag must be appended to the encrypted data.
nonceUint8ArrayNonce.
[addData]Uint8ArrayAdditional authenticated data.

EcJpake

A class implementing the EC J-PAKE protocol as defined by the Thread specification.

Kind: global class


ecJpake.getRound1() ⇒ Promise.<Uint8Array>

Generate a message for the first round of the protocol.

Kind: instance method of EcJpake
Returns: Promise.<Uint8Array> - Message data.


ecJpake.readRound1(buf) ⇒ Number

Read a message generated by the peer for the first round of the protocol.

Kind: instance method of EcJpake
Returns: Number - Number of bytes read.

ParamTypeDescription
bufUint8ArrayMessage data.

ecJpake.getRound2() ⇒ Promise.<Uint8Array>

Generate a message for the second round of the protocol.

Kind: instance method of EcJpake
Returns: Promise.<Uint8Array> - Message data.


ecJpake.readRound2(buf) ⇒ Number

Read a message generated by the peer for the second round of the protocol.

Kind: instance method of EcJpake
Returns: Number - Number of bytes read.

ParamTypeDescription
bufUint8ArrayMessage data.

ecJpake.deriveSecret() ⇒ Promise.<Uint8Array>

Derive the shared secret.

Kind: instance method of EcJpake
Returns: Promise.<Uint8Array> - Shared secret.


createAes128Cipher(key) ⇒ EncryptFunction

Create an AES-128 cipher operating in ECB mode.

Kind: global function
Returns: EncryptFunction - Encryption function.

ParamTypeDescription
keyUint8ArrayEncryption key. The key must be 16 bytes long.

getRandomBytes(size) ⇒ Promise.<Uint8Array>

Generate cryptographically strong random data.

Kind: global function
Returns: Promise.<Uint8Array> - Random data.

ParamTypeDescription
sizeNumberNumber of bytes to generate.

EncryptFunction ⇒ Promise.<Uint8Array>

Encrypt a single block of data.

Kind: global typedef
Returns: Promise.<Uint8Array> - Ciphertext block.

ParamTypeDescription
blockUint8ArrayPlaintext block. The block must be 16 bytes long.

RandomFunction ⇒ Promise.<Uint8Array>

Constructor.

Kind: global typedef
Returns: Promise.<Uint8Array> - Random bytes.

ParamTypeDefaultDescription
sizeNumberNumber of random bytes to generate.
optionsObjectOptions.
options.roleStringRole of this peer: client or server.
options.secretString | Uint8ArrayPre-shared secret.
[options.randomBytes]RandomFunctiongetRandomBytesCryptographically strong random generator function.
[options.curve]Stringp256Curve name.
[options.clientId]String | Uint8ArrayclientClient identity.
[options.serverId]String | Uint8ArrayserverServer identity.

NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests

FAQs

Package last updated on 09 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc