WebCrypto GOST Library

Pure Javascript implementation of WebCrypto API interfaces and Public Key Infrastructure for GOST algorithms (Russian Cryptographic Standards)

Current version 1.76

Download

  1. gostCrypto.src.zip Source files are very useful for debugging and learning
  2. gostCrypto.min.zip Minimized separate modules is recommended for use with AMD, requirejs or Node
  3. gostCrypto.dist.zip Assembled distribution is suitable for standard scenarios using the asynchronous calls

Note: Threre are only two files in assembled distribution package. For full functionality sufficient to include only file gostCrypto.dist.js. The second file gostEngine.dist.js will be executed asynchronously in the Worker mode if possible or included automatically.

Documentation

  1. Table of contents: source files, namespaces and classes
  2. GOST Engine low-level algorithms refs. GOST 28147, GOST R 34.10, GOST R 34.11, GOST R 34.12 and GOST R 34.13
  3. WebCrypto API basic cryptographic operations JavaScript API
  4. Public Key Infrastructure using X.509 provides facilities for handling certificates, CRLs, etc.
  5. Cryptographic Message Syntax implementats RFC-5652 specification.
  6. Private Key Management provides the ability to use the key store formats: PFX, CryptoPro, SignalCom and ViPNet.

Tests, examples and demonstration

  1. Self-Tests WebCrypto GOST algorithms

Base crypto scenarios and usage examples

  1. Example1 Digital Signature on documents
  2. Example2 Password based contents encryption
  3. Example3 Encryption for delivery messages through open channel

Integration with PKI work experimental tools

  1. Self-signed certificate generation in according to X.509 CA
  2. Certification request PKCS#10 format and certificate issue
  3. Certificate revocation and generation of X.509 CRL
  4. Sign and verify document PKCS#7 format complex example
  5. Encrypt and decrypt document PKCS#7 format complex example
  6. Export and import key store PKCS#12 format complex example

Demonstration of tools to work with key containers

  1. Export and import CryptoPro PrivateKey Container
  2. Export and import SignalCom PrivateKey Container
  3. Export and import ViPNet PrivateKey Container

Demonstration and experimental tools

  1. Convert data from/to different formats (char, hex, base64) and encodings (win1251, utf8, ascii)
  2. Calculate public key for pregenerated private key
  3. Verify signature for different sources and algorithm parameters
  4. View ASN.1 contents of BER-encoded data
  5. View Syntax JavaScript object of BER-encoded data

Summary

The library is compatible at the binary level with the following Russian Service Cryptographic Providers: The library supports the following high-level cryptographic protocols:

Public Key Infrastructure Using X.509

  • Generation of self-signed X.509 Certificates
  • Generation of PKCS#10 Certification Requests
  • Issue X.509 Certificates based on PKCS#10 Requests
  • Export/Import Certificates in the following formats: cer, p7c, p12
  • Issue X.509 Certificate Revocation Lists (CRL)
  • Export/Import CRLs in the following formats: crl, p7c, p12
  • Validation of Certification Path using trusted store
  • Encode/Decode SubjectPublicKeyInfo for a various GOST-based CSP

Content Digital Signature using PKCS#7 Cryptographic Message Syntax (CMS)

  • Generation of Attached and Detached Digital Signature
  • Signature based on SignedAttributes or direct on data content
  • Using SignedData format for delivery Certificates and CRLs
  • Encode/Decode SignatureValue for a various GOST-based CSP

Content Encryption using PKCS#7 Cryptographic Message Syntax (CMS)

  • Key Agreement Encryption Protocol
  • Transport Key Encryption Protocol
  • Secret Key based Encryption Protocol
  • Password based Key Encryption Protocol
  • Encode/Decode EncryptedKey and EncryptedContent for a various GOST-based CSPs

Key Store and Key Management

  • Export/Import PKCS#12 Key Store in the following formats: pfx
  • Export/Import Private and Secret Keys in the following formats: raw, p8, p8e, p12
  • Password-based Encryption of Asymmetric and Symmetric keys in Store
  • Encode/Decode PrivateKeyInfo for a various GOST-based CSPs
  • Binary compatibility of key container formats for the CryptoPro CSPs, the SignalCom CSPs and ViPNet CSPs
  • Ability to use an external Key Store for PKI operations

Support Syntax of Certificate Management over CMS (CMC)

The library implements follow low-level algorithms:

For these algorithms the library supports both 256 and 512 bits modes.

Web Cryptography API interface provides access to low-level algorithms in an asynchronous mode.

  • Key Management Functions: Generation, Wrapping and Derivation
  • Message Digest Functions
  • Encrypt/Decrypt Functions
  • Sign/Verify Functions

References

The library objects implements interface described in W3C standard

  1. Web Cryptography API

Library contains polyfill methods of Crypto and CryptoSubtle interfaces and extends algorithms for GOST-oriented crypto scenarios. For non-GOST algorithms execution passthrough to native CryptoSubtle method.

The library implements GOST methods and algorithms described in the following references

  1. RFC 5830 GOST 28147-89: RFC 5830 Encryption, Decryption, and Message Authentication Code (MAC) Algorithms
  2. RFC 5832 GOST R 34.10-2001: Digital Signature Algorithm (deprecated)
  3. RFC 7091 GOST R 34.10-2012: Digital Signature Algorithm
  4. RFC 5831 GOST R 34.11-94: Hash Function Algorithm (deprecated)
  5. RFC 6986 GOST R 34.11-2012: Hash Function Algorithm
  6. RFC 4357 Additional Cryptographic Algorithms for Use with GOST 28147-89, GOST R 34.10-94, GOST R 34.10-2001, and GOST R 34.11-94 Algorithms
  7. RFC 4490 Using the GOST 28147-89, GOST R 34.11-94, GOST R 34.10-94, and GOST R 34.10-2001 Algorithms with Cryptographic Message Syntax (CMS)
  8. RFC 4491 Using the GOST R 34.10-94, GOST R 34.10-2001, and GOST R 34.11-94 Algorithms with the Internet X.509 Public Key Infrastructure Certificate and CRL Profile

Base algorithms and PKCS standards described in the following references

  1. RFC 5912 New ASN.1 Modules for the Public Key Infrastructure Using X.509 (PKIX)
  2. RFC 3279 Algorithms and Identifiers for the Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile
  3. RFC 5280 Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile
  4. RFC 4211 Internet X.509 Public Key Infrastructure Certificate Request Message Format (CRMF)
  5. RFC 5272 Certificate Management over CMS (CMC)
  6. RFC 5273 Certificate Management over CMS (CMC): Transport Protocols
  7. RFC 5755 An Internet Attribute Certificate Profile for Authorization
  8. RFC 5750 Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Certificate Handling
  9. RFC 5751 Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Message Specification
  10. RFC 5652 Cryptographic Message Syntax (CMS)
  11. RFC 3560 Use of the RSAES-OAEP Key Transport Algorithm in the Cryptographic Message Syntax (CMS)
  12. RFC 3565 Use of the Advanced Encryption Standard (AES) Encryption Algorithm in Cryptographic Message Syntax (CMS)
  13. RFC 5753 Use of Elliptic Curve Cryptography (ECC) Algorithms in Cryptographic Message Syntax (CMS)
  14. RFC 5958 Asymmetric Key Packages
  15. RFC 6032 Cryptographic Message Syntax (CMS)Encrypted Key Package Content Type
  16. RFC 2898 PKCS #5: Password-Based Cryptography Specification
  17. RFC 2315 PKCS #7: Cryptographic Message Syntax Version 1.5
  18. RFC 5208 PKCS #8: Private-Key Information Syntax Specification Version 1.2
  19. RFC 2985 PKCS #9: Selected Object Classes and Attribute Types Version 2.0
  20. RFC 2986 PKCS #10: Certification Request Syntax Specification Version 1.7
  21. RFC 7292 PKCS #12: Personal Information Exchange Syntax v1.1

Feedback

Security is very important to us. If you have any issue regarding security, please disclose the information responsibly by sending an email to rudonick@gmail.com and not by creating a github issue. We do not offer commercial services to support the library, but if you would like contribute to development of the project your donation will be accepted with pleasure.

Rudolf Nickolaev, WebCrypto GOST team https://github.com/rudonick/crypto