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

sshsig

v0.3.1

Published

Provides SSH signature parser and verifier for SSH file signatures.

Downloads

19

Readme

SSH Sig

CI

Provides an SSH signature parser and verifier for SSH file signatures.

SSH signatures allow signing arbitrary files and can be used for signing git commits and tags.

All features are implemented using pure TypeScript and the built-in SubtleCrypto.

Since ed25519 public keys are not yet widely deployed, this package allows supplying custom SubtleCrypto implementation, such as webcrypto-ed25519.

Creating SSH signatures

SSH signatures can be created using OpenSSH's ssh-keygen:

ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file file_to_sign

This will create a detached signature in the file_to_sign.sig file.

Supported algorithms

The following algorithms are supported at this time:

  • RSA
  • ed25519[^1]
  • NIST P-256, P-384 and P-521[^2]
  • SSH U2F signatures (ECDSA and ed25519[^1])

[^1]: Requires support for Ed25519 algorithms (experimental in browsers, working in Deno)

[^2]: Requires support for P-521 (not available in Deno, so not tested)

This represents almost all available algorithms with the exception of DSA, which is unsupported by WebCrypto and obsolete.

If you encounter a problem verifying signatures with combinations of digests that we do not have in our testing suite, please file an issue attaching both the SSH signature and the file that was signed.

Examples

The following example verifies an ed25519 signature against provided data:

import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import { verify } from "./index.ts";

const signature = `-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgscJcEliU8+Su3ZZjI/dJmgzHje
UMEHlAAuMTvrYRCVwAAAAEZmlsZQAAAAAAAAAGc2hhNTEyAAAAUwAAAAtzc2gtZWQyNTUx
OQAAAECQkGDrATymoR1tunbphepkXiLGAMcF+Eca1EL3KpidzNYSTJ/smLYVw2elXq3K/l
dnvxJddvs2Z/x5En43hQIB
-----END SSH SIGNATURE-----`;

const valid = await verify(
  signature, // detached signature
  "this is signed data\n", // signed data
  {
    subtle: crypto.subtle, // bring your own SubtleCrypto
  },
);

assertEquals(valid, true, "signature is valid");

Signatures can also be parsed before verification. As signatures contain public keys it is also possible to export the public key in the SSH format:

import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import { verify } from "./index.ts";
import { parse } from "./sig_parser.ts";

const signature = parse(`-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgscJcEliU8+Su3ZZjI/dJmgzHje
UMEHlAAuMTvrYRCVwAAAAEZmlsZQAAAAAAAAAGc2hhNTEyAAAAUwAAAAtzc2gtZWQyNTUx
OQAAAECQkGDrATymoR1tunbphepkXiLGAMcF+Eca1EL3KpidzNYSTJ/smLYVw2elXq3K/l
dnvxJddvs2Z/x5En43hQIB
-----END SSH SIGNATURE-----`);

const valid = await verify(
  signature, // detached signature
  "this is signed data\n", // signed data
  // using "crypto.subtle" by default
);

assertEquals(valid, true, "signature is valid");
assertEquals(
  `${signature.publickey}`,
  "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILHCXBJYlPPkrt2WYyP3SZoMx43lDBB5QALjE762EQlc",
  "signing key",
);

License

This project is licensed under the Apache License, Version 2.0.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.