Socket
Socket
Sign inDemoInstall

ecdsa-sig-formatter

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecdsa-sig-formatter

Translate ECDSA signatures between ASN.1/DER and JOSE-style concatenation


Version published
Maintainers
1
Weekly downloads
15,232,864
increased by1.17%
Install size
53.1 kB

Weekly downloads

Package description

What is ecdsa-sig-formatter?

The ecdsa-sig-formatter npm package is used to convert ECDSA signatures from ASN.1/DER encoded format to JOSE/JWT compact serialization format and vice versa. This is particularly useful when working with JWTs and other security tokens in Node.js applications.

What are ecdsa-sig-formatter's main functionalities?

DER to JOSE conversion

Converts a DER-encoded ECDSA signature to JOSE format. The second parameter ('ES256') specifies the algorithm used, which determines the expected size of the signature.

const ecdsaSigFormatter = require('ecdsa-sig-formatter');
const derSignature = '...'; // DER-encoded signature
const joseSignature = ecdsaSigFormatter.derToJose(derSignature, 'ES256');

JOSE to DER conversion

Converts a JOSE-encoded ECDSA signature to ASN.1/DER format. Similar to the previous function, the algorithm ('ES256') needs to be specified.

const ecdsaSigFormatter = require('ecdsa-sig-formatter');
const joseSignature = '...'; // JOSE-encoded signature
const derSignature = ecdsaSigFormatter.joseToDer(joseSignature, 'ES256');

Other packages similar to ecdsa-sig-formatter

Readme

Source

ecdsa-sig-formatter

Build Status Coverage Status

Translate between JOSE and ASN.1/DER encodings for ECDSA signatures

Install

npm install ecdsa-sig-formatter --save

Usage

var format = require('ecdsa-sig-formatter');

var derSignature = '..'; // asn.1/DER encoded ecdsa signature

var joseSignature = format.derToJose(derSignature);

API


.derToJose(Buffer|String signature, String alg) -> String

Convert the ASN.1/DER encoded signature to a JOSE-style concatenated signature. Returns a base64 url encoded String.

  • If signature is a String, it should be base64 encoded
  • alg must be one of ES256, ES384 or ES512

.joseToDer(Buffer|String signature, String alg) -> Buffer

Convert the JOSE-style concatenated signature to an ASN.1/DER encoded signature. Returns a Buffer

  • If signature is a String, it should be base64 url encoded
  • alg must be one of ES256, ES384 or ES512

Contributing

  1. Fork the repository. Committing directly against this repository is highly discouraged.

  2. Make your modifications in a branch, updating and writing new unit tests as necessary in the spec directory.

  3. Ensure that all tests pass with npm test

  4. rebase your changes against master. Do not merge.

  5. Submit a pull request to this repository. Wait for tests to run and someone to chime in.

Code Style

This repository is configured with EditorConfig and ESLint rules.

Keywords

FAQs

Last updated on 25 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc