Have ideas to improve npm?Join in the discussion! »

    @ndn/keychain
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.20210203 • Public • Published

    @ndn/keychain

    This package is part of NDNts, Named Data Networking libraries for the modern web.

    This package provides signing algorithms, encryption algorithms, and certificate management features.

    The implementation uses Web Crypto API.

    • Modern browsers natively support WebCrypto.
    • Most browsers restrict WebCrypto to secure contexts only. During development, you may use http://localhost or ngrok.
    • In Node.js, @peculiar/webcrypto wraps Node.js Crypto API and exports them as WebCrypto.

    Signing Algorithms

    This package implements signature types defined in NDN Packet Format 0.3:

    • [X] DigestSha256 (in @ndn/packet package)
      • [X] signing and verification
    • [X] SignatureSha256WithRsa (RSASSA-PKCS1-v1_5)
      • [X] signing and verification
      • [X] KeyLocator .Name
      • [ ] KeyLocator .KeyDigest
    • [X] SignatureSha256WithEcdsa
      • [X] signing and verification
      • [X] KeyLocator .Name
      • [ ] KeyLocator .KeyDigest
    • [X] SignatureHmacWithSha256
      • [X] signing and verification
      • [ ] KeyLocator matching

    Both Interest and Data are signable.

    • [X] sign Interest
      • [X] put certificate name in KeyLocator
      • [X] generate SigNonce, SigTime, SigSeqNum
    • [X] verify Interest
      • [X] check ParametersSha256DigestComponent
      • [X] check SigNonce, SigTime, SigSeqNum
    • [X] sign Data
      • [X] put certificate name in KeyLocator
    • [X] verify Data

    Encryption Algorithms

    • [X] AES-CBC
      • [X] low-level encryption and decryption
    • [X] AES-CTR and AES-GCM
      • [X] low-level encryption and decryption
      • [X] generate unique IV
      • [X] check IV uniqueness
    • [X] RSA-OAEP
      • [X] low-level encryption and decryption

    Certificate Management and Storage

    Certificate class provides basic operations with NDN Certificate Format 2.0.

    • [X] generate self-signed certificate
    • [X] issue certificate to another public key
    • [X] import certificate as PublicKey for RSASSA-PKCS1-v1_5 and ECDSA

    KeyChain class provides storage of PrivateKey and Certificate. It could be ephemeral or persistent. KeyChain.createTemp() creates an in-memory ephemeral keychain. KeyChain.open(locator) opens a persistent keychain.

    Persistent keychain in Node.js uses JSON files as underlying storage. The locator argument should be a filesystem directory where these files are stored. Private keys are saved as JSON Web Key (JWK) format, so that it's important to protect the storage directory. It is unsafe to simultaneously construct multiple KeyChain instances on the same storage directory or access the same keychain from multiple Node.js processes.

    Persistent keychain in browser uses IndexedDB API. The locator argument determines the database name(s). Private keys are saved as non-extractable CryptoKey objects.

    Known Issues

    • In Firefox, persistent keychain stores JWK instead of CryptoKey, due to Mozilla Bug 1545813.
    • In Firefox, persistent keychain is unusable in a Private Browsing window, due to Mozilla Bug 781982.
    • In Chrome, AES 192-bit key is not supported.
    • In iOS and macOS Safari, ECDSA P-521 curve is not supported.

    Install

    npm i @ndn/keychain

    DownloadsWeekly Downloads

    12

    Version

    0.0.20210203

    License

    ISC

    Unpacked Size

    157 kB

    Total Files

    82

    Last publish

    Collaborators

    • avatar