npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@particle/device-control-crypto

v1.1.3

Published

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

Downloads

40

Readme

@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.

| Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | Options. | | options.encrypt | EncryptFunction | | Encryption function. | | options.nonceLength | Number | | Nonce length in bytes. The value must be in the range [7, 13]. | | [options.tagLength] | Number | 16 | Length 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.

| Param | Type | Description | | --- | --- | --- | | data | Uint8Array | Data to encrypt. | | nonce | Uint8Array | Nonce. | | [addData] | Uint8Array | Additional 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.

| Param | Type | Description | | --- | --- | --- | | data | Uint8Array | Data to decrypt. The authentication tag must be appended to the encrypted data. | | nonce | Uint8Array | Nonce. | | [addData] | Uint8Array | Additional 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.

| Param | Type | Description | | --- | --- | --- | | buf | Uint8Array | Message 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.

| Param | Type | Description | | --- | --- | --- | | buf | Uint8Array | Message 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.

| Param | Type | Description | | --- | --- | --- | | key | Uint8Array | Encryption 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.

| Param | Type | Description | | --- | --- | --- | | size | Number | Number of bytes to generate. |


EncryptFunction ⇒ Promise.<Uint8Array>

Encrypt a single block of data.

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

| Param | Type | Description | | --- | --- | --- | | block | Uint8Array | Plaintext block. The block must be 16 bytes long. |


RandomFunction ⇒ Promise.<Uint8Array>

Constructor.

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

| Param | Type | Default | Description | | --- | --- | --- | --- | | size | Number | | Number of random bytes to generate. | | options | Object | | Options. | | options.role | String | | Role of this peer: client or server. | | options.secret | String | Uint8Array | | Pre-shared secret. | | [options.randomBytes] | RandomFunction | getRandomBytes | Cryptographically strong random generator function. | | [options.curve] | String | p256 | Curve name. | | [options.clientId] | String | Uint8Array | client | Client identity. | | [options.serverId] | String | Uint8Array | server | Server identity. |


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