{"name":"kruptein","version":"2.2.0","description":"crypto; from kruptein to hide or conceal","keywords":["crypto","cryptography","cryptr","crypter","encryption","decryption","encrypt","decrypt","AES","GCM","authenticated","authenticate","unicode","symmetric","cipher","key derivation","scrypt","pbkdf2","security"],"author":{"name":"Jason Gerfen","email":"jason.gerfen@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jas-/kruptein.git"},"bugs":{"url":"https://github.com/jas-/kruptein/issues"},"devDependencies":{"codecov":"^3.7.2","expect.js":"^0.3.1","mocha":"^7.1.1","nyc":"^15.1.0"},"scripts":{"cover":"nyc report --reporter=text-lcov > coverage.lcov && codecov","test":"nyc mocha test/*.js"},"engines":{"node":">6"},"dependencies":{"asn1.js-rfc2560":"^5.0.1"},"gitHead":"27aed760ecd8704e63f68e53ee090d74825cddca","homepage":"https://github.com/jas-/kruptein#readme","_id":"kruptein@2.2.0","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-6zpHVg2A9Hp6npw7YQHkSHT1EZ9zY60crEmc9qSC39LfCu+wFhg3S0ts4mwkLtqPgm7Yg6t2LwljweMhZTAphw==","shasum":"455a1998a1b8d81d70d61189a231adf8c71dab12","tarball":"http://registry-npm.ywwl.com/kruptein/download/kruptein-2.2.0.tgz","fileCount":9,"unpackedSize":36024,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjGOHCRA9TVsSAnZWagAAMMsP/11noCSCAebQit/vYpK3\ncvDYDG7E+ViNyScvlEcnOSTADYoxaOf3Z3dy9uApKKEJLZ48/rpy2gvKfAMB\nM2fiE7ohT2rk9EmjakZutXVD/tAzGFP/ghCQLaEEtndw3pjS/NhahO3wCxmy\nPelY6q8gXp2UoEXDU/4TXo+7otDdr71fPj3Hq69xxrfUAflwC8EktvvSfKuy\nTNFWBjyUCEglxJLUaiCMjv5/Diidx1G0k6/+mqEqERZjZ7BJ1bzYWWdugPZr\nldg3J8wyNefnkgPMJLxe9F9fpvTv/GLM0FAYNnVwYD68CQGxaWYs6F/7+40P\nRgfwAsjNpaoxdzYdoGqWyQUatqQCsXIhtlWp9jufBYQfd4Ir0ljdPl1A46l9\nJxGgkdKx9XCcrl1XNWMnLRFShiLZSVef4tzhUDwcPLrMo7WcTGhDWUxEw5eu\nPGfiRi6hPUzCp3OQESAiJ+rh/h78xOeVKdXUeXVHZ5Ar/nLN1GdANzmXvED4\nyN0sRjXo8bc/mXt+fVafoi6j33BCUyt+SrkWp+5BAPdR6xQMuwGsISF7OCLF\nTZnb0zU/g0YMuztPnQ+YfOCsGiA0Ju8qS+2pApFYJCJ85Aetm5HolywxN8rs\nUs8Z9i9C4o+tlhE7n4n/P4clovhA+lGJEnFsX+qhy4g8txEoAvTdkFSCqviX\nVOYH\r\n=QBXF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUhN4h8JrxQ6VPORNBRq7FEHgpK97sryWZSPDlMsu48wIhAOHsQMVyoq8QzdX/2hdEOjx91R6UlBRQq2+KNARLYWDr"}],"size":12562,"noattachment":false,"key":"/kruptein/-/kruptein-2.2.0.tgz"},"maintainers":[{"name":"jas-","email":"jason.gerfen@gmail.com"}],"_npmUser":{"name":"jas-","email":"jason.gerfen@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/kruptein_2.2.0_1603036039439_0.5175158404258065"},"_hasShrinkwrap":false,"readme":"kruptein\n========\ncrypto; from `kruptein` to hide or conceal.\n\n[![npm](https://img.shields.io/npm/v/kruptein.svg)](https://npmjs.com/package/kruptein)\n![Downloads](https://img.shields.io/npm/dm/kruptein.svg)\n[![Known Vulnerabilities](https://snyk.io/test/github/jas-/kruptein/badge.svg)](https://snyk.io/test/github/jas-/kruptein)\n![Build Status](https://github.com/jas-/kruptein/actions/workflows/node.js.yml/badge.svg)\n\nSandbox\n-------\nTo test the module feel free to use the [sandbox](https://codesandbox.io/p/sandbox/kruptein-test-1z9zgd?file=%2Findex.js)\n\nInstall\n-------\nTo install `npm install kruptein`\n\nMethods\n-------\n*   `.set(secret, plaintext, [aad], callback)`\n*   `.get(secret, ciphertext, [{at: auth_tag, aad: aad}], callback)`\n\nOptions\n-------\nIndustry standards are used for the algorithm, hashing algorithm, key & IV sizes. The default key derivation\nis pbkdf2, however use of the scrypt derivation function can be enabled.\n*   `algorithm`: (Optional) Cipher algorithm from `crypto.getCiphers()`. Default: `aes-256-gcm`.\n*   `hashing`: (Optional) Hash algorithm from `crypto.getHashes()`. Default: `sha512`.\n*   `encodeas`: (Optional) Output encoding. Currently supports `binary`, `hex`, & `base64`. Default: `base64`.\n*   `key_size`: (Optional) Key size bytes (should match block size of algorithm). Default: `32`\n*   `iv_size`: (Optional) IV size bytes. Default: `16`.\n*   `at_size`: (Optional) Authentication tag size. Applicable to `gcm` & `ocb` cipher modes. Default: `128`.\n*   `use_scrypt`: (Optional) Use `.scrypt()` to derive a key. Requires node > v10. Default/Fallback: `.pbkdf2()`.\n*   `use_asn1`: (Optional) Disable the default ASN.1 encoding. Default: true\n\nUsage\n-----\nWhen selecting an algorithm from `crypto.getCiphers()` the\n`iv` and `key_size` values are calculated auto-magically to make implementation\neasy.\n\nYou can always define your own if the defaults per algorithm and mode\naren't what you would like; see the `options` section above.\n\nCreate ciphertext from plaintext\n-----------------\nTo create a new ciphertext object. Run [example](https://codesandbox.io/p/devtool/task-log/cldvsajy7000hfqgja6e28q8c?project=1z9zgd) to encrypt plaintext.\n\n```javascript\nconst kruptein = require(\"kruptein\")(opts);\nlet secret = \"squirrel\";\n\nkruptein.set(secret, \"Operation mincemeat was an example of deception\", (err, ct) => {\n  if (err)\n    throw err;\n\n  console.log(ct);\n});\n```\n\nGet plaintext from ciphertext\n------------------\nTo retrieve plaintext from a ciphertext object. Run [example](https://codesandbox.io/p/devtool/task-log/cldvn1j3f0007fqgjgqzle28o?project=1z9zgd) to decrypt ciphertext.\n\n```javascript\nconst kruptein = require(\"kruptein\")(opts);\nlet ciphertext, secret = \"squirrel\";\n\nkruptein.get(secret, ciphertext, (err, pt) => {\n  if (err)\n    throw err;\n\n  console.log(pt);\n});\n```\n\nOutput\n------\nThe `.set()` method output depends on three factors; the `encodeas`,\n`algorithm` and `use_asn1`.\n\nFor any algorithm that supports authentication (AEAD), the object\nstructure includes the `Authentication Tag` and the `Additional\nAuthentication Data` attribute and value.\n\nWhen the `use_asn1` option is enabled (default is true), the result is an [ASN.1](https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/)\nvalue using the `encodeas` value. While this is a more complex\nencoding option, it helps standardize & minimize the resulting\nciphertext output.\n\n\nTest harness\n------------\nThe included test harness, invoked with `npm test`, makes every\nattempt to trap and handle errors. Some of which come from side\nchannel or possible malability of the resultant ciphertext.\n\nThis can be seen within the `test/index.js` CI test harness under\nthe HMAC, AT & AAD validation test cases.\n\nAn online playgound for experimenting with the module can also be\nfound [here](https://codesandbox.io/p/devtool/task-log/cldvmxl6k0003fqgj0dc2es4x?project=1z9zgd)\n\nCryptography References\n-----------------------\nThis module conforms to industry recommendations regarding algorithm type,\nmode, key size, iv size & implementation, digests, key derivation & management\netc. References used provided here:\n\n**RFC:**\n*   [RFC 2104](https://tools.ietf.org/html/rfc2104): HMAC: Keyed-Hashing for Message Authentication\n*   [RFC 4086](https://tools.ietf.org/html/rfc4086): Randomness Requirements for Security\n*   [RFC 5084](https://tools.ietf.org/html/rfc5084): Using AES-CCM and AES-GCM Authenticated Encryption\n*   [RFC 7914](https://tools.ietf.org/html/rfc7914): The scrypt Password-Based Key Derivation Function\n*   [RFC 8018](https://tools.ietf.org/html/rfc8018): Password-Based Cryptography Specification\n*   [X.697](https://www.itu.int/rec/T-REC-X.697-201710-I/en): ASN.1 encoding rules: Specifications of JavaScript Object Notation Encoding Rules (JER)\n\n**NIST:**\n*   [SP 800-38A](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf): Block cipher modes of operation\n*   [SP 800-38B](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf): Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC\n*   [SP 800-57P1](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf): Recommendations for key management\n*   [SP 800-107](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-107r1.pdf): Recommendation for Applications Using Approved Hash Algorithms\n*   [SP 800-108](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-108.pdf): Recommendation for Key Derivation Using Pseudorandom Functions\n*   [SP 800-131A](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf): Transitioning the Use of Cryptographic Algorithms and Key Lengths\n*   [SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf): Recommendation for Password-Based Key Derivation\n*   [SP 800-175B](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-175B.pdf): Guideline for Using Cryptographic Standards in the Federal Government\n\n**FIPS:**\n*   [FIPS 197](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf): Advanced Encryption Standard (AES)\n*   [FIPS 198-1](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.198-1.pdf): The Keyed-Hash Message Authentication Code (HMAC)\n*   [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf): Secure Hash Standard (SHS)\n\nContributing\n------------\nContributions are welcome & appreciated!\n\nRefer to the [contributing document](https://github.com/jas-/kruptein/blob/master/CONTRIBUTING.md)\nto help facilitate pull requests.\n\nLicense\n-------\nThis software is licensed under the [MIT License](https://github.com/jas-/kruptein/blob/master/LICENSE).\n\nCopyright Jason Gerfen, 2019 to 2023.\n","publish_time":1603036039539,"_cnpm_publish_time":1603036039539,"dist-tags":{"latest":"4.0.1"}}