You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

4 years ago
  1. # ecdsa-sig-formatter
  2. [![Build Status](https://travis-ci.org/Brightspace/node-ecdsa-sig-formatter.svg?branch=master)](https://travis-ci.org/Brightspace/node-ecdsa-sig-formatter) [![Coverage Status](https://coveralls.io/repos/Brightspace/node-ecdsa-sig-formatter/badge.svg)](https://coveralls.io/r/Brightspace/node-ecdsa-sig-formatter)
  3. Translate between JOSE and ASN.1/DER encodings for ECDSA signatures
  4. ## Install
  5. ```sh
  6. npm install ecdsa-sig-formatter --save
  7. ```
  8. ## Usage
  9. ```js
  10. var format = require('ecdsa-sig-formatter');
  11. var derSignature = '..'; // asn.1/DER encoded ecdsa signature
  12. var joseSignature = format.derToJose(derSignature);
  13. ```
  14. ### API
  15. ---
  16. #### `.derToJose(Buffer|String signature, String alg)` -> `String`
  17. Convert the ASN.1/DER encoded signature to a JOSE-style concatenated signature.
  18. Returns a _base64 url_ encoded `String`.
  19. * If _signature_ is a `String`, it should be _base64_ encoded
  20. * _alg_ must be one of _ES256_, _ES384_ or _ES512_
  21. ---
  22. #### `.joseToDer(Buffer|String signature, String alg)` -> `Buffer`
  23. Convert the JOSE-style concatenated signature to an ASN.1/DER encoded
  24. signature. Returns a `Buffer`
  25. * If _signature_ is a `String`, it should be _base64 url_ encoded
  26. * _alg_ must be one of _ES256_, _ES384_ or _ES512_
  27. ## Contributing
  28. 1. **Fork** the repository. Committing directly against this repository is
  29. highly discouraged.
  30. 2. Make your modifications in a branch, updating and writing new unit tests
  31. as necessary in the `spec` directory.
  32. 3. Ensure that all tests pass with `npm test`
  33. 4. `rebase` your changes against master. *Do not merge*.
  34. 5. Submit a pull request to this repository. Wait for tests to run and someone
  35. to chime in.
  36. ### Code Style
  37. This repository is configured with [EditorConfig][EditorConfig] and
  38. [ESLint][ESLint] rules.
  39. [EditorConfig]: http://editorconfig.org/
  40. [ESLint]: http://eslint.org