a zip code crypto-currency system good for red ONLY

asn1.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
  2. // Fedor, you are amazing.
  3. 'use strict'
  4. var asn1 = require('asn1.js')
  5. exports.certificate = require('./certificate')
  6. var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
  7. this.seq().obj(
  8. this.key('version').int(),
  9. this.key('modulus').int(),
  10. this.key('publicExponent').int(),
  11. this.key('privateExponent').int(),
  12. this.key('prime1').int(),
  13. this.key('prime2').int(),
  14. this.key('exponent1').int(),
  15. this.key('exponent2').int(),
  16. this.key('coefficient').int()
  17. )
  18. })
  19. exports.RSAPrivateKey = RSAPrivateKey
  20. var RSAPublicKey = asn1.define('RSAPublicKey', function () {
  21. this.seq().obj(
  22. this.key('modulus').int(),
  23. this.key('publicExponent').int()
  24. )
  25. })
  26. exports.RSAPublicKey = RSAPublicKey
  27. var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
  28. this.seq().obj(
  29. this.key('algorithm').use(AlgorithmIdentifier),
  30. this.key('subjectPublicKey').bitstr()
  31. )
  32. })
  33. exports.PublicKey = PublicKey
  34. var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
  35. this.seq().obj(
  36. this.key('algorithm').objid(),
  37. this.key('none').null_().optional(),
  38. this.key('curve').objid().optional(),
  39. this.key('params').seq().obj(
  40. this.key('p').int(),
  41. this.key('q').int(),
  42. this.key('g').int()
  43. ).optional()
  44. )
  45. })
  46. var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
  47. this.seq().obj(
  48. this.key('version').int(),
  49. this.key('algorithm').use(AlgorithmIdentifier),
  50. this.key('subjectPrivateKey').octstr()
  51. )
  52. })
  53. exports.PrivateKey = PrivateKeyInfo
  54. var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
  55. this.seq().obj(
  56. this.key('algorithm').seq().obj(
  57. this.key('id').objid(),
  58. this.key('decrypt').seq().obj(
  59. this.key('kde').seq().obj(
  60. this.key('id').objid(),
  61. this.key('kdeparams').seq().obj(
  62. this.key('salt').octstr(),
  63. this.key('iters').int()
  64. )
  65. ),
  66. this.key('cipher').seq().obj(
  67. this.key('algo').objid(),
  68. this.key('iv').octstr()
  69. )
  70. )
  71. ),
  72. this.key('subjectPrivateKey').octstr()
  73. )
  74. })
  75. exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
  76. var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
  77. this.seq().obj(
  78. this.key('version').int(),
  79. this.key('p').int(),
  80. this.key('q').int(),
  81. this.key('g').int(),
  82. this.key('pub_key').int(),
  83. this.key('priv_key').int()
  84. )
  85. })
  86. exports.DSAPrivateKey = DSAPrivateKey
  87. exports.DSAparam = asn1.define('DSAparam', function () {
  88. this.int()
  89. })
  90. var ECPrivateKey = asn1.define('ECPrivateKey', function () {
  91. this.seq().obj(
  92. this.key('version').int(),
  93. this.key('privateKey').octstr(),
  94. this.key('parameters').optional().explicit(0).use(ECParameters),
  95. this.key('publicKey').optional().explicit(1).bitstr()
  96. )
  97. })
  98. exports.ECPrivateKey = ECPrivateKey
  99. var ECParameters = asn1.define('ECParameters', function () {
  100. this.choice({
  101. namedCurve: this.objid()
  102. })
  103. })
  104. exports.signature = asn1.define('signature', function () {
  105. this.seq().obj(
  106. this.key('r').int(),
  107. this.key('s').int()
  108. )
  109. })