Index of every page on this site: llms.txt
All skills
jasnell avatar

/node-crypto

@5f83e6c
Run it yourself

Modern node:crypto and WebCrypto: Argon2 password hashing, post-quantum ML-KEM/ML-DSA/SLH-DSA, KMAC, SHA-3/SHAKE, AES-SIV/GCM-SIV/OCB, ChaCha20-Poly1305, UUIDv7, PKCS#12 parsing and X.509 certificate generation. Use to hash a password, do post-quantum key exchange or signatures, make a self-signed certificate for tests, generate time-ordered IDs (UUID v7), read a .p12/.pfx, or fix CryptoKey, setEngine or SHAKE outputLength errors. Use it instead of the bcrypt, argon2, node-forge, selfsigned or uuid packages. Covers crypto.argon2, encapsulate/decapsulate, createMac, SubtleCrypto.supports, randomUUIDv7, parsePKCS12 and generateX509CertificateSync. Node.js 24.7+.

Use this Skill: https://skilld.dev/gh/jasnell/node-skills/node-crypto

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesciphers.md

≈500 tokens on demand. Your agent reads this file only when SKILL.md points to it.

AEAD ciphers

Cipher node:crypto WebCrypto
aes-*-ocb since v10.10.0; authTagLength required AES-OCB v24.7.0 (1.1)
chacha20-poly1305 since v11.2.0; 16-byte tag default ChaCha20-Poly1305 v24.7.0 (1.1)
aes-{128,192,256}-siv v26.8.0, v24.22.0 —
aes-{128,192,256}-gcm-siv (OpenSSL 3.2+) v26.8.0, v24.22.0 —

Feature-detect with getCiphers().includes('aes-256-gcm-siv'). getCipherInfo() reports mode: 'siv' / 'gcm-siv'.

SIV and GCM-SIV rules (from the docs, exercised in ciphers.mjs)

  • The tag is always 16 bytes.
  • AES-SIV keys are double length: aes-128-siv takes a 32-byte key.
  • AES-SIV uses no IV, so pass null. If the protocol has a nonce, pass it as the last setAAD() call. Up to 126 AAD inputs are allowed.
  • AES-GCM-SIV takes a 12-byte IV and is nonce-misuse resistant.
  • Call update() exactly once (the whole message), then final(). Streaming with write()/pipe() may fail.
  • On decrypt, setAuthTag() must come before update(). The same is true for CCM. GCM, OCB, and chacha20-poly1305 only need it before final().
  • Zero-length plaintext needs OpenSSL 3.5+.

Provider ciphers (v26.9.0, v24.22.0)

createCipheriv also exposes provider ciphers such as SM4-GCM, SM4-CCM, SM4-XTS, CBC-CTS (option ctsMode: 'CS1'|'CS2'|'CS3'), and AES key-wrap variants (xtsStandard: 'GB'|'IEEE' for sm4-xts). These were not exercised here.

GCM tag length (DEP0182)

Decrypting with a tag shorter than 16 bytes without authTagLength on the decipher:

  • v24: works, emits a DEP0182 warning.
  • v26+: throws ERR_CRYPTO_INVALID_AUTH_TAG ("Invalid authentication tag length").

Fix: pass the same authTagLength to both createCipheriv and createDecipheriv.

WebCrypto

AES-OCB and ChaCha20-Poly1305 take { name, iv, additionalData?, tagLength? }. The 16-byte tag is appended to the ciphertext. Keys use 'raw-secret' or 'jwk'; 'raw' is not accepted.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    This skill provides comprehensive documentation and code examples for modern Node.js native cryptography and WebCrypto APIs (v24.7+). It demonstrates built-in features for password hashing, post-quantum crypto, and certificate management without requiring external dependencies.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at 5f83e6c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated last week

README badge

README badge for jasnell/node-skills/node-crypto