test-utils.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. var utils = require('../lib/utils');
  2. var fs = require('fs');
  3. var path = require('path');
  4. var assert = require('assert');
  5. var t = -1;
  6. var group = path.basename(__filename, '.js') + '/';
  7. var fixturesdir = path.join(__dirname, 'fixtures');
  8. var tests = [
  9. { run: function() {
  10. var what = this.what;
  11. var r;
  12. assert.strictEqual(r = utils.readInt(new Buffer([0,0,0]), 0),
  13. false,
  14. makeMsg(what, 'Wrong result: ' + r));
  15. next();
  16. },
  17. what: 'readInt - without stream callback - failure #1'
  18. },
  19. { run: function() {
  20. var what = this.what;
  21. var r;
  22. assert.strictEqual(r = utils.readInt(new Buffer([]), 0),
  23. false,
  24. makeMsg(what, 'Wrong result: ' + r));
  25. next();
  26. },
  27. what: 'readInt - without stream callback - failure #2'
  28. },
  29. { run: function() {
  30. var what = this.what;
  31. var r;
  32. assert.strictEqual(r = utils.readInt(new Buffer([0,0,0,5]), 0),
  33. 5,
  34. makeMsg(what, 'Wrong result: ' + r));
  35. next();
  36. },
  37. what: 'readInt - without stream callback - success'
  38. },
  39. { run: function() {
  40. var what = this.what;
  41. var callback = function() {};
  42. var stream = {
  43. _cleanup: function(cb) {
  44. cleanupCalled = true;
  45. assert(cb === callback, makeMsg(what, 'Wrong callback'));
  46. }
  47. };
  48. var cleanupCalled = false;
  49. var r;
  50. assert.strictEqual(r = utils.readInt(new Buffer([]), 0, stream, callback),
  51. false,
  52. makeMsg(what, 'Wrong result: ' + r));
  53. assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
  54. next();
  55. },
  56. what: 'readInt - with stream callback'
  57. },
  58. { run: function() {
  59. var what = this.what;
  60. var r;
  61. assert.strictEqual(r = utils.readString(new Buffer([0,0,0]), 0),
  62. false,
  63. makeMsg(what, 'Wrong result: ' + r));
  64. next();
  65. },
  66. what: 'readString - without stream callback - bad length #1'
  67. },
  68. { run: function() {
  69. var what = this.what;
  70. var r;
  71. assert.strictEqual(r = utils.readString(new Buffer([]), 0),
  72. false,
  73. makeMsg(what, 'Wrong result: ' + r));
  74. next();
  75. },
  76. what: 'readString - without stream callback - bad length #2'
  77. },
  78. { run: function() {
  79. var what = this.what;
  80. var r;
  81. assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1,5]), 0),
  82. new Buffer([5]),
  83. makeMsg(what, 'Wrong result: ' + r));
  84. next();
  85. },
  86. what: 'readString - without stream callback - success'
  87. },
  88. { run: function() {
  89. var what = this.what;
  90. var r;
  91. assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1,33]), 0, 'ascii'),
  92. '!',
  93. makeMsg(what, 'Wrong result: ' + r));
  94. next();
  95. },
  96. what: 'readString - without stream callback - encoding'
  97. },
  98. { run: function() {
  99. var what = this.what;
  100. var callback = function() {};
  101. var stream = {
  102. _cleanup: function(cb) {
  103. cleanupCalled = true;
  104. assert(cb === callback, makeMsg(what, 'Wrong callback'));
  105. }
  106. };
  107. var cleanupCalled = false;
  108. var r;
  109. assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1]),
  110. 0,
  111. stream,
  112. callback),
  113. false,
  114. makeMsg(what, 'Wrong result: ' + r));
  115. assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
  116. next();
  117. },
  118. what: 'readString - with stream callback - no encoding'
  119. },
  120. { run: function() {
  121. var what = this.what;
  122. var callback = function() {};
  123. var stream = {
  124. _cleanup: function(cb) {
  125. cleanupCalled = true;
  126. assert(cb === callback, makeMsg(what, 'Wrong callback'));
  127. }
  128. };
  129. var cleanupCalled = false;
  130. var r;
  131. assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1]),
  132. 0,
  133. 'ascii',
  134. stream,
  135. callback),
  136. false,
  137. makeMsg(what, 'Wrong result: ' + r));
  138. assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
  139. next();
  140. },
  141. what: 'readString - with stream callback - encoding'
  142. },
  143. { run: function() {
  144. var what = this.what;
  145. var filepath = fixturesdir + '/encrypted-rsa.ppk';
  146. var passphrase = 'node.js';
  147. var keyInfo = utils.parseKey(fs.readFileSync(filepath));
  148. utils.decryptKey(keyInfo, passphrase);
  149. var expPrivOrig = new Buffer([
  150. 45,45,45,45,45,66,69,71,73,78,32,82,83,65,32,80,82,73,86,65,84,69,32,75,
  151. 69,89,45,45,45,45,45,10,77,73,73,67,87,81,73,66,65,65,75,66,103,71,115,
  152. 70,89,82,77,66,85,68,73,109,97,52,48,98,110,101,80,66,77,48,79,86,115,
  153. 104,119,102,109,87,115,83,57,122,72,113,88,72,108,115,122,111,81,113,68,
  154. 82,101,89,52,103,102,51,10,112,87,112,83,78,76,116,53,70,70,78,77,80,50,
  155. 87,107,69,68,121,70,105,71,83,115,54,77,55,72,51,102,56,108,89,72,43,108,
  156. 120,85,51,122,56,72,99,78,103,101,121,70,80,48,52,70,98,85,77,75,83,115,
  157. 51,67,54,51,97,108,10,115,110,97,104,107,52,71,75,117,71,69,67,118,55,71,
  158. 112,89,87,118,102,110,110,85,87,112,118,78,111,73,104,101,107,52,113,53,
  159. 117,118,103,82,119,106,65,75,75,107,71,88,111,47,69,116,82,74,56,101,68,
  160. 65,103,69,108,65,111,71,65,10,85,43,71,102,72,76,118,88,69,111,122,81,49,
  161. 109,72,65,56,77,102,99,69,109,67,83,104,76,55,83,77,86,81,78,50,119,80,
  162. 76,56,72,102,103,73,109,89,108,55,43,97,72,112,87,69,56,100,101,49,110,
  163. 109,100,116,119,121,54,112,50,10,52,80,89,50,80,85,89,81,57,80,89,53,55,
  164. 105,51,122,76,56,78,90,100,56,87,81,55,82,103,48,82,66,72,68,108,110,100,
  165. 97,70,101,70,52,69,102,48,117,76,98,111,113,89,100,47,120,78,48,114,122,
  166. 102,121,53,53,122,55,104,87,10,79,76,43,56,86,104,111,120,84,114,66,85,
  167. 118,118,101,79,104,90,119,66,80,107,79,101,72,102,120,109,107,86,122,51,
  168. 120,98,98,114,103,51,107,78,108,111,48,67,81,81,68,74,89,80,75,116,67,
  169. 115,47,108,52,54,75,74,109,78,51,108,10,85,65,78,100,73,52,81,73,117,87,
  170. 81,43,90,108,108,122,55,112,57,52,70,102,100,111,116,110,107,118,113,71,
  171. 43,43,66,112,49,119,79,113,74,83,67,105,104,54,85,86,105,119,76,102,118,
  172. 112,78,90,116,71,77,67,116,107,52,54,87,78,10,104,99,48,122,65,107,69,65,
  173. 105,65,121,78,52,87,85,115,47,48,120,52,87,111,118,71,57,53,54,74,49,65,
  174. 43,117,83,69,75,101,87,122,117,113,102,112,71,71,98,87,103,90,57,88,102,
  175. 110,80,110,107,43,49,65,108,56,70,79,87,49,10,116,117,57,87,87,114,77,80,
  176. 73,97,118,81,110,90,87,47,100,88,120,104,107,101,78,87,84,72,55,56,99,81,
  177. 74,66,65,76,107,77,43,113,122,90,103,77,86,112,90,79,48,107,115,68,113,
  178. 65,52,72,56,90,116,53,108,81,97,102,81,109,10,115,120,67,87,70,102,43,
  179. 108,101,53,67,110,114,97,70,113,87,78,103,104,119,82,115,70,99,112,67,84,
  180. 116,110,52,56,54,98,97,109,121,56,57,104,115,85,100,113,105,76,50,83,54,
  181. 121,103,97,70,111,69,67,81,70,68,107,51,114,49,101,10,119,77,56,109,106,
  182. 77,65,51,98,50,76,77,43,65,71,77,121,72,51,43,71,80,102,53,57,113,119,
  183. 102,76,86,88,80,77,103,101,84,90,117,98,103,84,116,55,119,52,102,54,87,
  184. 98,65,118,111,81,83,56,67,114,119,48,97,68,86,98,72,10,118,102,76,85,86,
  185. 98,67,119,114,57,112,49,66,77,48,67,81,70,83,66,106,67,97,47,102,122,101,
  186. 73,67,86,107,80,70,66,97,75,81,85,109,88,106,81,51,73,99,80,84,79,114,57,
  187. 48,109,83,65,105,80,110,65,65,112,112,83,119,84,10,106,53,83,89,83,102,
  188. 69,57,114,83,86,98,43,69,104,81,48,104,107,50,86,75,87,73,102,111,99,78,
  189. 72,66,68,49,77,65,78,57,122,98,52,61,10,45,45,45,45,45,69,78,68,32,82,83,
  190. 65,32,80,82,73,86,65,84,69,32,75,69,89,45,45,45,45,45
  191. ]);
  192. assert(keyInfo.ppk === true, makeMsg(what, 'Expected PPK flag'));
  193. assert(keyInfo._converted === true,
  194. makeMsg(what, 'Expected automatic private PEM generation'));
  195. assert(keyInfo._macresult === true,
  196. makeMsg(what, 'Expected successful MAC verification'));
  197. assert(keyInfo._decrypted === true,
  198. makeMsg(what, 'Expected decrypted flag'));
  199. assert.deepEqual(keyInfo.privateOrig,
  200. expPrivOrig,
  201. makeMsg(what, 'Decrypted private PEM data mismatch'));
  202. next();
  203. },
  204. what: 'decryptKey - with encrypted RSA PPK'
  205. },
  206. { run: function() {
  207. var what = this.what;
  208. var filepath = fixturesdir + '/encrypted-dsa.ppk';
  209. var passphrase = 'node.js';
  210. var keyInfo = utils.parseKey(fs.readFileSync(filepath));
  211. utils.decryptKey(keyInfo, passphrase);
  212. var expPrivOrig = new Buffer([
  213. 45,45,45,45,45,66,69,71,73,78,32,68,83,65,32,80,82,73,86,65,84,69,32,75,
  214. 69,89,45,45,45,45,45,10,77,73,73,66,117,103,73,66,65,65,75,66,103,81,67,
  215. 90,57,105,80,71,72,110,48,97,78,119,98,66,72,111,112,48,76,102,67,107,
  216. 79,72,66,77,103,75,119,76,79,50,80,49,117,57,57,54,69,85,109,68,105,77,
  217. 49,104,100,83,98,116,10,100,117,77,114,67,113,53,111,78,113,74,76,47,116,
  218. 79,81,109,72,73,49,100,50,75,101,65,77,48,72,113,74,109,65,74,89,74,103,
  219. 102,43,56,81,104,74,49,109,104,74,56,81,115,65,77,90,113,54,121,84,74,
  220. 106,54,53,77,68,89,120,10,122,105,73,117,56,106,79,85,68,104,80,100,67,
  221. 68,80,48,80,105,67,81,79,66,68,119,88,48,109,47,108,54,47,72,50,73,97,54,
  222. 101,100,121,106,82,49,85,112,51,78,105,112,68,113,113,97,78,104,98,67,73,
  223. 119,73,86,65,76,103,50,10,85,47,110,81,97,114,74,83,113,114,89,72,122,90,
  224. 87,72,47,68,109,80,100,80,80,66,65,111,71,65,72,107,104,113,74,118,83,
  225. 121,122,88,99,51,77,65,104,53,120,110,56,83,106,90,120,77,57,43,101,83,
  226. 105,69,119,65,48,56,89,105,10,75,81,98,53,48,70,118,110,103,120,56,69,76,
  227. 121,77,79,108,100,106,110,79,57,50,121,103,114,117,87,89,113,50,90,105,
  228. 68,70,117,99,79,105,111,48,70,99,74,76,107,65,97,66,102,83,113,75,118,57,
  229. 114,117,108,88,110,114,55,83,47,10,97,81,43,107,119,99,48,105,122,70,99,
  230. 79,97,86,100,122,53,104,79,80,119,118,51,105,52,109,108,77,87,83,121,66,
  231. 51,87,56,54,97,106,53,65,76,119,70,65,97,49,121,112,73,57,73,111,56,51,
  232. 68,99,119,113,100,88,55,104,102,66,10,57,75,98,48,102,77,107,67,103,89,
  233. 65,109,118,86,43,107,113,87,104,85,103,68,89,119,78,78,122,49,113,68,97,
  234. 111,83,56,88,100,115,79,112,111,110,117,116,90,47,48,115,116,82,81,54,54,
  235. 109,75,65,121,56,107,78,86,78,78,81,54,10,111,85,120,49,88,70,108,49,87,
  236. 85,116,52,105,121,70,89,47,50,82,122,50,102,90,104,76,122,53,47,84,98,90,
  237. 82,75,53,121,103,111,54,54,54,87,103,110,120,66,47,85,100,52,71,65,120,
  238. 47,66,80,81,84,103,104,79,74,74,79,76,10,48,48,118,74,107,43,56,106,86,
  239. 67,71,78,68,99,57,52,50,86,54,110,70,88,122,110,68,77,88,119,113,120,104,
  240. 82,67,87,54,100,109,43,50,108,84,104,55,110,116,114,108,105,56,109,67,
  241. 107,53,103,73,85,67,74,90,75,65,77,65,122,10,107,121,114,50,118,108,50,
  242. 80,101,52,56,97,100,105,56,86,115,57,115,61,10,45,45,45,45,45,69,78,68,
  243. 32,68,83,65,32,80,82,73,86,65,84,69,32,75,69,89,45,45,45,45,45,
  244. ]);
  245. assert(keyInfo.ppk === true, makeMsg(what, 'Expected PPK flag'));
  246. assert(keyInfo._converted === true,
  247. makeMsg(what, 'Expected automatic private PEM generation'));
  248. assert(keyInfo._macresult === true,
  249. makeMsg(what, 'Expected successful MAC verification'));
  250. assert(keyInfo._decrypted === true,
  251. makeMsg(what, 'Expected decrypted flag'));
  252. assert.deepEqual(keyInfo.privateOrig,
  253. expPrivOrig,
  254. makeMsg(what, 'Decrypted private PEM data mismatch'));
  255. next();
  256. },
  257. what: 'decryptKey - with encrypted DSA PPK'
  258. },
  259. { run: function() {
  260. var what = this.what;
  261. var filepath = fixturesdir + '/id_rsa_enc';
  262. var passphrase = 'foobarbaz';
  263. var keyInfo = utils.parseKey(fs.readFileSync(filepath));
  264. utils.decryptKey(keyInfo, passphrase);
  265. var expPriv = new Buffer([
  266. 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
  267. 0xec, 0x9f, 0xd7, 0x6e, 0x17, 0xfa, 0xe4, 0xc5, 0xff, 0xac, 0x83, 0x6e,
  268. 0xbe, 0x60, 0x66, 0xb2, 0xf2, 0x6a, 0x34, 0xfa, 0x4f, 0xe2, 0x49, 0xcd,
  269. 0x54, 0x29, 0x34, 0x95, 0x3b, 0x55, 0xc1, 0xf5, 0x1f, 0x16, 0x3f, 0x6a,
  270. 0x9f, 0xe5, 0x93, 0x7c, 0x25, 0xe0, 0x92, 0xdb, 0x63, 0x8d, 0xbb, 0xb4,
  271. 0xc2, 0x24, 0x7c, 0x9c, 0x69, 0x4c, 0xe0, 0xa7, 0x21, 0xac, 0xfc, 0xd3,
  272. 0x44, 0x3b, 0x1a, 0xaf, 0x9e, 0x60, 0x93, 0x09, 0xd3, 0xac, 0xb4, 0x65,
  273. 0x88, 0x39, 0x85, 0x8c, 0xd2, 0x04, 0x2c, 0xaf, 0x85, 0x27, 0x92, 0x59,
  274. 0x1b, 0x28, 0x73, 0x99, 0xf9, 0xc1, 0x6c, 0x37, 0x08, 0xa2, 0x77, 0x58,
  275. 0x5a, 0x8c, 0xb0, 0x96, 0xc0, 0x63, 0x8a, 0x10, 0x10, 0x84, 0xd8, 0xfa,
  276. 0x1e, 0xb7, 0x27, 0x58, 0xc1, 0x6b, 0x34, 0xb4, 0xe6, 0xa1, 0x05, 0x68,
  277. 0x82, 0xc9, 0xe3, 0x6a, 0x6f, 0x0b, 0xb5, 0xf7, 0x13, 0xa8, 0x8b, 0x14,
  278. 0x4a, 0x6e, 0x0a, 0x72, 0x39, 0xa6, 0x1f, 0xa0, 0x4f, 0xcb, 0x72, 0xd9,
  279. 0xe5, 0x61, 0x61, 0xa7, 0x63, 0x53, 0xae, 0x66, 0xd6, 0xba, 0xb4, 0xda,
  280. 0x98, 0x92, 0xb4, 0x50, 0x93, 0x36, 0xdf, 0x9a, 0xfe, 0x58, 0x36, 0x6d,
  281. 0x31, 0xd7, 0xff, 0x01, 0x88, 0xe4, 0x49, 0x3b, 0x71, 0x8f, 0x09, 0xe6,
  282. 0x6f, 0xc9, 0xe1, 0x98, 0x51, 0x8c, 0xc4, 0xfa, 0x16, 0xb9, 0x45, 0x14,
  283. 0x7b, 0x9e, 0x0e, 0x09, 0x6d, 0x07, 0x1e, 0x79, 0x4e, 0xa1, 0xb6, 0xf0,
  284. 0xdd, 0x0a, 0x3d, 0xa3, 0x9c, 0xf4, 0xeb, 0x5f, 0xaa, 0x29, 0x37, 0x8c,
  285. 0xb4, 0x03, 0x25, 0xac, 0xe8, 0x64, 0xf6, 0x07, 0xbe, 0xca, 0xc8, 0x48,
  286. 0x39, 0x51, 0xaf, 0x36, 0x42, 0xdd, 0x32, 0x7d, 0x37, 0x7a, 0xdd, 0xd6,
  287. 0xbf, 0x57, 0xf9, 0x10, 0xd7, 0x9f, 0xe4, 0xb8, 0xc8, 0xa7, 0x1b, 0x0c,
  288. 0x89, 0x69, 0xf0, 0x9d, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01,
  289. 0x01, 0x00, 0xcb, 0xad, 0x9a, 0xe6, 0x6d, 0x45, 0xcd, 0x7e, 0x91, 0x61,
  290. 0x91, 0x90, 0xd5, 0xd6, 0x6d, 0x10, 0x43, 0x92, 0x20, 0x20, 0x06, 0x7b,
  291. 0x26, 0x43, 0xd3, 0xd9, 0xd4, 0x25, 0x50, 0x79, 0xb5, 0x06, 0xa5, 0xc7,
  292. 0xa4, 0xb6, 0xc7, 0x03, 0xfa, 0x3b, 0xb6, 0xee, 0xe3, 0xfa, 0x6c, 0x6b,
  293. 0x27, 0xd3, 0xa3, 0xf9, 0x7c, 0x39, 0xb6, 0x7a, 0x32, 0x36, 0x2a, 0xca,
  294. 0x98, 0xa5, 0xd1, 0xe9, 0x7e, 0x43, 0x04, 0xf4, 0xe4, 0x1c, 0x65, 0x54,
  295. 0x17, 0xc3, 0xfd, 0xca, 0x65, 0xa6, 0x9d, 0x70, 0x72, 0x76, 0x73, 0x0b,
  296. 0x68, 0xf1, 0xc2, 0x6a, 0xc3, 0x77, 0x1a, 0x80, 0xe0, 0x01, 0x4f, 0x31,
  297. 0x69, 0xc1, 0x67, 0xd0, 0x0a, 0x80, 0xf9, 0x01, 0xb5, 0x69, 0xb6, 0x8e,
  298. 0x63, 0xa6, 0x88, 0xa1, 0xe7, 0x00, 0x83, 0x1d, 0x20, 0xb5, 0x46, 0x7f,
  299. 0xfc, 0x03, 0xc5, 0xf0, 0xba, 0x0c, 0x77, 0xa1, 0x80, 0xf2, 0x90, 0xcf,
  300. 0x0a, 0x57, 0x14, 0xa0, 0xc7, 0x30, 0x5b, 0x10, 0x2c, 0x78, 0x85, 0xa2,
  301. 0x52, 0x7e, 0xf1, 0xa8, 0xd0, 0xbc, 0x78, 0x3e, 0x7e, 0xf6, 0xc5, 0xc5,
  302. 0xac, 0xf3, 0x02, 0xd4, 0xdc, 0x02, 0x20, 0xb8, 0xcc, 0x37, 0xe1, 0xaa,
  303. 0x2d, 0x24, 0xed, 0x44, 0xfb, 0x77, 0x20, 0xe5, 0xc4, 0x38, 0x63, 0x08,
  304. 0xe2, 0x92, 0xd2, 0x6a, 0xdf, 0x0a, 0xcb, 0x54, 0x97, 0x91, 0xc7, 0x55,
  305. 0x9c, 0x31, 0x00, 0xe2, 0xf2, 0x25, 0xda, 0xd8, 0x6c, 0xea, 0x6d, 0xf2,
  306. 0xff, 0x98, 0x16, 0x17, 0xf5, 0xfa, 0x5c, 0xd8, 0xfd, 0x8a, 0xf7, 0xea,
  307. 0x35, 0xa0, 0x96, 0xbd, 0xed, 0xd3, 0x35, 0x1c, 0xee, 0x78, 0xa3, 0x1f,
  308. 0xfd, 0x0c, 0x24, 0x4b, 0xad, 0x4f, 0xa5, 0x08, 0xb3, 0xd7, 0x90, 0xe7,
  309. 0x08, 0x60, 0x52, 0x26, 0xee, 0x93, 0x40, 0x80, 0xd1, 0xaf, 0xaf, 0x74,
  310. 0x4d, 0x3b, 0x6f, 0x4e, 0x42, 0x91, 0x02, 0x81, 0x81, 0x00, 0xfe, 0x26,
  311. 0x9d, 0x81, 0xa1, 0xf3, 0xe2, 0x48, 0xad, 0x22, 0x4d, 0xf4, 0x1c, 0x68,
  312. 0x4d, 0xe1, 0xe2, 0xff, 0x09, 0xbf, 0xa6, 0x12, 0x0a, 0x16, 0xce, 0xd6,
  313. 0x34, 0x73, 0x7d, 0x55, 0xd3, 0x35, 0x6f, 0xb2, 0x4d, 0x64, 0xcb, 0x5e,
  314. 0x5e, 0x1a, 0xc8, 0xcf, 0x29, 0x58, 0x28, 0x30, 0xec, 0x29, 0x95, 0x09,
  315. 0x1b, 0x11, 0x80, 0xba, 0xe0, 0x16, 0x99, 0x49, 0x76, 0xb3, 0x42, 0x72,
  316. 0x05, 0x10, 0xf2, 0xf5, 0xa8, 0x36, 0x84, 0xf1, 0x83, 0x57, 0x5d, 0x27,
  317. 0xae, 0xe9, 0xae, 0x13, 0x47, 0xf3, 0xda, 0xb1, 0x42, 0xde, 0xa1, 0x25,
  318. 0xc7, 0x72, 0xee, 0x2e, 0x34, 0x78, 0x64, 0x6a, 0xed, 0x91, 0x81, 0xaf,
  319. 0x1e, 0xd3, 0xed, 0x68, 0x91, 0x37, 0x2f, 0xdd, 0x57, 0x5d, 0x2a, 0x3a,
  320. 0x21, 0x86, 0x74, 0x6d, 0xff, 0x0b, 0x56, 0xac, 0xc2, 0x65, 0x3a, 0x88,
  321. 0x91, 0x5e, 0x3c, 0x10, 0x7e, 0x53, 0x02, 0x81, 0x81, 0x00, 0xee, 0x58,
  322. 0x94, 0xcc, 0x96, 0x1b, 0x9a, 0x63, 0x84, 0x45, 0x7c, 0x92, 0x78, 0x35,
  323. 0x17, 0x7e, 0x7f, 0x7d, 0x6f, 0x06, 0x77, 0x69, 0x5c, 0xc4, 0xe8, 0xc7,
  324. 0x19, 0xd2, 0x5e, 0x58, 0xd2, 0x1d, 0xee, 0x4c, 0xf2, 0xd9, 0xcb, 0xca,
  325. 0x2a, 0x27, 0xec, 0x5b, 0x55, 0x37, 0x66, 0x0d, 0x2c, 0xe6, 0xfd, 0x48,
  326. 0x35, 0x51, 0x66, 0x13, 0x1e, 0xab, 0x70, 0xda, 0xe6, 0x45, 0xac, 0x25,
  327. 0x8b, 0x2b, 0x89, 0x4b, 0x19, 0x99, 0x6a, 0x06, 0x81, 0x24, 0xd5, 0xa9,
  328. 0x3c, 0xf6, 0xc4, 0x28, 0x39, 0x70, 0x24, 0x0d, 0x8d, 0xcd, 0x69, 0xb4,
  329. 0x65, 0x78, 0x0d, 0xaf, 0x4f, 0x68, 0xe3, 0xac, 0x9d, 0xaf, 0x07, 0x93,
  330. 0x10, 0xeb, 0xc9, 0x40, 0x8c, 0x82, 0x85, 0x85, 0x16, 0xc0, 0xfc, 0x49,
  331. 0x76, 0x03, 0x63, 0x7a, 0x2c, 0x95, 0x61, 0xc8, 0x3b, 0x07, 0x79, 0x68,
  332. 0x60, 0xb1, 0xc8, 0xf0, 0x97, 0x4f, 0x02, 0x81, 0x81, 0x00, 0xe4, 0xa3,
  333. 0x3c, 0xa3, 0x38, 0x5d, 0x3d, 0x3f, 0x00, 0x72, 0x92, 0x0a, 0x7f, 0xdb,
  334. 0xdd, 0xe4, 0xce, 0xdf, 0x7d, 0x97, 0xaa, 0x01, 0x24, 0x8e, 0x6c, 0x39,
  335. 0x0c, 0x2a, 0xb1, 0xa0, 0x9a, 0x47, 0xc2, 0x5a, 0x77, 0x81, 0xab, 0xeb,
  336. 0x13, 0x61, 0xa9, 0x31, 0xa5, 0x12, 0x27, 0xe6, 0x0b, 0x2f, 0x45, 0x62,
  337. 0x51, 0xb5, 0xa7, 0x47, 0x76, 0xfd, 0x1d, 0x9d, 0x97, 0x69, 0xa0, 0xe7,
  338. 0x0e, 0x63, 0xb7, 0x0f, 0x04, 0xeb, 0x37, 0x22, 0x46, 0x74, 0x3b, 0xdb,
  339. 0xcd, 0x61, 0x70, 0x36, 0xec, 0x4e, 0x16, 0x79, 0xcd, 0x9c, 0x97, 0x00,
  340. 0x73, 0xb3, 0x93, 0x4e, 0x81, 0xe9, 0xa4, 0xfd, 0x05, 0x08, 0x17, 0xd0,
  341. 0xc1, 0x3d, 0x0a, 0xa1, 0x3d, 0xb2, 0x96, 0x1e, 0xdb, 0xcf, 0x76, 0x83,
  342. 0xa1, 0x51, 0x62, 0x40, 0xea, 0x66, 0xfa, 0xec, 0xa4, 0x5d, 0x89, 0x10,
  343. 0xff, 0x25, 0xf5, 0x87, 0x28, 0xfd, 0x02, 0x81, 0x80, 0x0e, 0xb4, 0x22,
  344. 0x41, 0xd8, 0xc4, 0xcd, 0x2a, 0x74, 0x7f, 0x80, 0xe6, 0xdc, 0x49, 0x92,
  345. 0x30, 0x78, 0x96, 0xf9, 0x61, 0x71, 0xbe, 0x6b, 0x3d, 0xae, 0x8a, 0x91,
  346. 0xda, 0x3b, 0x7d, 0xc9, 0x40, 0x95, 0x71, 0xe3, 0xcd, 0x71, 0xd7, 0xff,
  347. 0xef, 0xc4, 0x92, 0x01, 0xd8, 0xd0, 0x0f, 0xe2, 0x04, 0x41, 0xfd, 0xd1,
  348. 0x64, 0x3b, 0x22, 0xd4, 0xd2, 0x88, 0xbc, 0xc8, 0x55, 0xe5, 0xff, 0xce,
  349. 0xed, 0x19, 0xa4, 0x2b, 0x69, 0x1e, 0x74, 0x56, 0x45, 0x3a, 0x75, 0x1d,
  350. 0x50, 0xaf, 0xdb, 0x37, 0x67, 0xe6, 0xa1, 0x7b, 0x6c, 0xff, 0xa7, 0x64,
  351. 0x57, 0x1a, 0xa9, 0x05, 0x02, 0x18, 0x81, 0x8e, 0x9c, 0xbc, 0x9f, 0xe2,
  352. 0xfc, 0x58, 0xc7, 0x05, 0xa4, 0x0b, 0xae, 0xa1, 0x2f, 0xb8, 0xa0, 0xa3,
  353. 0x8a, 0x23, 0xf9, 0xe6, 0x84, 0x34, 0xab, 0x10, 0x91, 0x2e, 0x79, 0x34,
  354. 0xf5, 0xe2, 0xca, 0x8c, 0xdb, 0x02, 0x81, 0x81, 0x00, 0x8e, 0x9e, 0xc9,
  355. 0xc2, 0xdf, 0xf7, 0x36, 0xef, 0x6e, 0x2a, 0x36, 0xeb, 0xd7, 0xa4, 0x52,
  356. 0x43, 0x27, 0x8d, 0xaa, 0x52, 0x2d, 0xa8, 0xc1, 0x66, 0xf4, 0x9f, 0xc6,
  357. 0x78, 0x9e, 0x31, 0x64, 0xe6, 0x56, 0xc9, 0x6d, 0x85, 0x79, 0x2a, 0x5c,
  358. 0xca, 0x53, 0x2b, 0x1a, 0x46, 0xf4, 0x16, 0x60, 0xfe, 0x41, 0xcf, 0xc7,
  359. 0x74, 0x57, 0xd0, 0x06, 0xf4, 0xc9, 0xfa, 0x47, 0x9c, 0xa2, 0xcb, 0xe0,
  360. 0x85, 0xc5, 0x95, 0x9f, 0x35, 0xdd, 0x4c, 0x15, 0x7a, 0xda, 0x34, 0xc4,
  361. 0x81, 0x20, 0x7d, 0x55, 0x85, 0xee, 0x24, 0xa7, 0xa6, 0xcb, 0x0a, 0xec,
  362. 0xa8, 0x13, 0x4a, 0xc4, 0xaa, 0x5a, 0x4c, 0xf9, 0x32, 0xc0, 0x4b, 0x65,
  363. 0x47, 0x65, 0xba, 0x38, 0x57, 0x17, 0x0c, 0xdd, 0xe1, 0x68, 0xd1, 0x4f,
  364. 0x3d, 0xb9, 0x0e, 0xdd, 0x3f, 0x53, 0xe6, 0x91, 0x0e, 0x33, 0xba, 0x77,
  365. 0xc2, 0x03, 0xf5, 0x90, 0x60, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  366. ]);
  367. var expPrivOrig = [
  368. '-----BEGIN RSA PRIVATE KEY-----',
  369. 'MIIEpQIBAAKCAQEA7J/Xbhf65MX/rINuvmBmsvJqNPpP4knNVCk0lTtVwfUfFj9qn+WTfC',
  370. 'Xgkttjjbu0wiR8nGlM4KchrPzTRDsar55gkwnTrLRliDmFjNIELK+FJ5JZGyhzmfnBbDcI',
  371. 'ondYWoywlsBjihAQhNj6HrcnWMFrNLTmoQVogsnjam8LtfcTqIsUSm4KcjmmH6BPy3LZ5W',
  372. 'Fhp2NTrmbWurTamJK0UJM235r+WDZtMdf/AYjkSTtxjwnmb8nhmFGMxPoWuUUUe54OCW0H',
  373. 'HnlOobbw3Qo9o5z061+qKTeMtAMlrOhk9ge+yshIOVGvNkLdMn03et3Wv1f5ENef5LjIpx',
  374. 'sMiWnwnQIDAQABAoIBAQDLrZrmbUXNfpFhkZDV1m0QQ5IgIAZ7JkPT2dQlUHm1BqXHpLbH',
  375. 'A/o7tu7j+mxrJ9Oj+Xw5tnoyNirKmKXR6X5DBPTkHGVUF8P9ymWmnXBydnMLaPHCasN3Go',
  376. 'DgAU8xacFn0AqA+QG1abaOY6aIoecAgx0gtUZ//APF8LoMd6GA8pDPClcUoMcwWxAseIWi',
  377. 'Un7xqNC8eD5+9sXFrPMC1NwCILjMN+GqLSTtRPt3IOXEOGMI4pLSat8Ky1SXkcdVnDEA4v',
  378. 'Il2ths6m3y/5gWF/X6XNj9ivfqNaCWve3TNRzueKMf/QwkS61PpQiz15DnCGBSJu6TQIDR',
  379. 'r690TTtvTkKRAoGBAP4mnYGh8+JIrSJN9BxoTeHi/wm/phIKFs7WNHN9VdM1b7JNZMteXh',
  380. 'rIzylYKDDsKZUJGxGAuuAWmUl2s0JyBRDy9ag2hPGDV10nrumuE0fz2rFC3qElx3LuLjR4',
  381. 'ZGrtkYGvHtPtaJE3L91XXSo6IYZ0bf8LVqzCZTqIkV48EH5TAoGBAO5YlMyWG5pjhEV8kn',
  382. 'g1F35/fW8Gd2lcxOjHGdJeWNId7kzy2cvKKifsW1U3Zg0s5v1INVFmEx6rcNrmRawliyuJ',
  383. 'SxmZagaBJNWpPPbEKDlwJA2NzWm0ZXgNr09o46ydrweTEOvJQIyChYUWwPxJdgNjeiyVYc',
  384. 'g7B3loYLHI8JdPAoGBAOSjPKM4XT0/AHKSCn/b3eTO332XqgEkjmw5DCqxoJpHwlp3gavr',
  385. 'E2GpMaUSJ+YLL0ViUbWnR3b9HZ2XaaDnDmO3DwTrNyJGdDvbzWFwNuxOFnnNnJcAc7OTTo',
  386. 'HppP0FCBfQwT0KoT2ylh7bz3aDoVFiQOpm+uykXYkQ/yX1hyj9AoGADrQiQdjEzSp0f4Dm',
  387. '3EmSMHiW+WFxvms9roqR2jt9yUCVcePNcdf/78SSAdjQD+IEQf3RZDsi1NKIvMhV5f/O7R',
  388. 'mkK2kedFZFOnUdUK/bN2fmoXts/6dkVxqpBQIYgY6cvJ/i/FjHBaQLrqEvuKCjiiP55oQ0',
  389. 'qxCRLnk09eLKjNsCgYEAjp7Jwt/3Nu9uKjbr16RSQyeNqlItqMFm9J/GeJ4xZOZWyW2FeS',
  390. 'pcylMrGkb0FmD+Qc/HdFfQBvTJ+kecosvghcWVnzXdTBV62jTEgSB9VYXuJKemywrsqBNK',
  391. 'xKpaTPkywEtlR2W6OFcXDN3haNFPPbkO3T9T5pEOM7p3wgP1kGAHBwcHBwcH',
  392. '-----END RSA PRIVATE KEY-----'
  393. ].join('\n');
  394. assert(keyInfo.ppk === undefined, makeMsg(what, 'Unexpected PPK flag'));
  395. assert(keyInfo._converted === undefined,
  396. makeMsg(what, 'Unexpected automatic private PEM generation'));
  397. assert(keyInfo._macresult === undefined,
  398. makeMsg(what, 'Unexpected MAC verification'));
  399. assert(keyInfo._decrypted === true,
  400. makeMsg(what, 'Expected decrypted flag'));
  401. assert.deepEqual(keyInfo.private,
  402. expPriv,
  403. makeMsg(what, 'Decrypted private data mismatch'));
  404. assert.deepEqual(keyInfo.privateOrig,
  405. expPrivOrig,
  406. makeMsg(what, 'Decrypted private PEM data mismatch'));
  407. next();
  408. },
  409. what: 'decryptKey - with encrypted RSA'
  410. },
  411. { run: function() {
  412. var pubkey = [
  413. '---- BEGIN SSH2 PUBLIC KEY ----',
  414. 'Comment: "dsa-key-20151028"',
  415. 'AAAAB3NzaC1kc3MAAAEBAJ0Gth9JHw/a8RmY3Y0UFqBWVWkzWxkzG+DR2oqHwTIq',
  416. 'jAi9Xr06oSbdmXd3Jl3bHsbd2gVq4+/j32s0uIf6FEW7mFooSiDOcRWARJSAAmkI',
  417. 'T9ep//ag+gNUmwhtPebliCqcAn9VWE7wq2v0FJsG3trFW/pvi/hVsBOrkz4Qieqb',
  418. 'KbwNwZc/MI+h9KAQPV7tWN2y5aG3jlVD9PERyeFPlmYkD1P+IqytxvL3thUFKeru',
  419. 'N8w+hjKIGGonEcVzWRJ9UUBQqAaNNH4/9mzedpS8CivfnUvsIw9rSTB4N+Wf70jb',
  420. '6a2qD1mHs1DqOkX136UOn5HkFldBnny0NSmlR/LewQkAAAAVAMu94kPPMR0Ew6Zh',
  421. 'mAoJJc0RjisBAAABAGkOU/b/I0opGITGCx9qFEcqiJ/VJHVsYhQgM/jCkydEc9kW',
  422. 'yjY+wKulGWpmA8wGmYm9j4IAgMGEXjBR8dyYJNZVXK0JOJmWrqUj5Q1GCUS5hCyU',
  423. 'iA7nmVQ4syhGE49aFBLFdyKS6t7//swEEEV+6Hw9qcQWB98zoD8qdPGz3W/9kNXB',
  424. 'OgVHWyqfWsbA/7MW2vjjF/u2EJe8YRKIJnodLOSNwPf0iCmj1HdaIm5N2Nl1k/6/',
  425. '9MwlY6tjn4hinrEN/pOiC1ci/1ADmTq4L9upi1Paix51zD8Yp7q3SxOgZqFU0ELF',
  426. 'VP/XHokm278t1mE9hxDwkepv7XgBda8uamWzwSoAAAEAYl2bjiCjIB68+DNuRgtf',
  427. 'lvVk00nOH3dYXSslwKIFTivYDczjz0splaLsEhrdTRiOXyVsCEDhYtlvWlTw34rg',
  428. 's2QoutpqISOiq26XwPdOlejD7Hy7gtw3yRyrhbXHYHE0nOvx0/SP7il4ub//QRTd',
  429. '7cUPao2f359cGpap84anqKJjF3m4oRGdZGhTAQPqtGMkchZvItKyZe6pJ9HhsE7h',
  430. 'NMsxPHAUon8QwNL1v+JkHg7i+Oe8rEZx/51m/qGVtXLN+z885lsqzuwe9KhY5I8C',
  431. 'C3f8nR+Mivfp1ce9pSMKCpdRASzOBuykZKYZmns6SA0UqAp7ZLDKubbhk9ZLVyAO',
  432. 'dA==',
  433. '---- END SSH2 PUBLIC KEY ----'
  434. ].join('\n');
  435. assert.doesNotThrow(function() {
  436. var res = utils.genPublicKey(utils.parseKey(pubkey));
  437. assert.deepEqual(
  438. res,
  439. { type: 'dss',
  440. fulltype: 'ssh-dss',
  441. curve: undefined,
  442. public: new Buffer([
  443. 0x00, 0x00, 0x00, 0x07, 0x73, 0x73, 0x68, 0x2d, 0x64, 0x73, 0x73,
  444. 0x00, 0x00, 0x01, 0x01, 0x00, 0x9d, 0x06, 0xb6, 0x1f, 0x49, 0x1f,
  445. 0x0f, 0xda, 0xf1, 0x19, 0x98, 0xdd, 0x8d, 0x14, 0x16, 0xa0, 0x56,
  446. 0x55, 0x69, 0x33, 0x5b, 0x19, 0x33, 0x1b, 0xe0, 0xd1, 0xda, 0x8a,
  447. 0x87, 0xc1, 0x32, 0x2a, 0x8c, 0x08, 0xbd, 0x5e, 0xbd, 0x3a, 0xa1,
  448. 0x26, 0xdd, 0x99, 0x77, 0x77, 0x26, 0x5d, 0xdb, 0x1e, 0xc6, 0xdd,
  449. 0xda, 0x05, 0x6a, 0xe3, 0xef, 0xe3, 0xdf, 0x6b, 0x34, 0xb8, 0x87,
  450. 0xfa, 0x14, 0x45, 0xbb, 0x98, 0x5a, 0x28, 0x4a, 0x20, 0xce, 0x71,
  451. 0x15, 0x80, 0x44, 0x94, 0x80, 0x02, 0x69, 0x08, 0x4f, 0xd7, 0xa9,
  452. 0xff, 0xf6, 0xa0, 0xfa, 0x03, 0x54, 0x9b, 0x08, 0x6d, 0x3d, 0xe6,
  453. 0xe5, 0x88, 0x2a, 0x9c, 0x02, 0x7f, 0x55, 0x58, 0x4e, 0xf0, 0xab,
  454. 0x6b, 0xf4, 0x14, 0x9b, 0x06, 0xde, 0xda, 0xc5, 0x5b, 0xfa, 0x6f,
  455. 0x8b, 0xf8, 0x55, 0xb0, 0x13, 0xab, 0x93, 0x3e, 0x10, 0x89, 0xea,
  456. 0x9b, 0x29, 0xbc, 0x0d, 0xc1, 0x97, 0x3f, 0x30, 0x8f, 0xa1, 0xf4,
  457. 0xa0, 0x10, 0x3d, 0x5e, 0xed, 0x58, 0xdd, 0xb2, 0xe5, 0xa1, 0xb7,
  458. 0x8e, 0x55, 0x43, 0xf4, 0xf1, 0x11, 0xc9, 0xe1, 0x4f, 0x96, 0x66,
  459. 0x24, 0x0f, 0x53, 0xfe, 0x22, 0xac, 0xad, 0xc6, 0xf2, 0xf7, 0xb6,
  460. 0x15, 0x05, 0x29, 0xea, 0xee, 0x37, 0xcc, 0x3e, 0x86, 0x32, 0x88,
  461. 0x18, 0x6a, 0x27, 0x11, 0xc5, 0x73, 0x59, 0x12, 0x7d, 0x51, 0x40,
  462. 0x50, 0xa8, 0x06, 0x8d, 0x34, 0x7e, 0x3f, 0xf6, 0x6c, 0xde, 0x76,
  463. 0x94, 0xbc, 0x0a, 0x2b, 0xdf, 0x9d, 0x4b, 0xec, 0x23, 0x0f, 0x6b,
  464. 0x49, 0x30, 0x78, 0x37, 0xe5, 0x9f, 0xef, 0x48, 0xdb, 0xe9, 0xad,
  465. 0xaa, 0x0f, 0x59, 0x87, 0xb3, 0x50, 0xea, 0x3a, 0x45, 0xf5, 0xdf,
  466. 0xa5, 0x0e, 0x9f, 0x91, 0xe4, 0x16, 0x57, 0x41, 0x9e, 0x7c, 0xb4,
  467. 0x35, 0x29, 0xa5, 0x47, 0xf2, 0xde, 0xc1, 0x09, 0x00, 0x00, 0x00,
  468. 0x15, 0x00, 0xcb, 0xbd, 0xe2, 0x43, 0xcf, 0x31, 0x1d, 0x04, 0xc3,
  469. 0xa6, 0x61, 0x98, 0x0a, 0x09, 0x25, 0xcd, 0x11, 0x8e, 0x2b, 0x01,
  470. 0x00, 0x00, 0x01, 0x00, 0x69, 0x0e, 0x53, 0xf6, 0xff, 0x23, 0x4a,
  471. 0x29, 0x18, 0x84, 0xc6, 0x0b, 0x1f, 0x6a, 0x14, 0x47, 0x2a, 0x88,
  472. 0x9f, 0xd5, 0x24, 0x75, 0x6c, 0x62, 0x14, 0x20, 0x33, 0xf8, 0xc2,
  473. 0x93, 0x27, 0x44, 0x73, 0xd9, 0x16, 0xca, 0x36, 0x3e, 0xc0, 0xab,
  474. 0xa5, 0x19, 0x6a, 0x66, 0x03, 0xcc, 0x06, 0x99, 0x89, 0xbd, 0x8f,
  475. 0x82, 0x00, 0x80, 0xc1, 0x84, 0x5e, 0x30, 0x51, 0xf1, 0xdc, 0x98,
  476. 0x24, 0xd6, 0x55, 0x5c, 0xad, 0x09, 0x38, 0x99, 0x96, 0xae, 0xa5,
  477. 0x23, 0xe5, 0x0d, 0x46, 0x09, 0x44, 0xb9, 0x84, 0x2c, 0x94, 0x88,
  478. 0x0e, 0xe7, 0x99, 0x54, 0x38, 0xb3, 0x28, 0x46, 0x13, 0x8f, 0x5a,
  479. 0x14, 0x12, 0xc5, 0x77, 0x22, 0x92, 0xea, 0xde, 0xff, 0xfe, 0xcc,
  480. 0x04, 0x10, 0x45, 0x7e, 0xe8, 0x7c, 0x3d, 0xa9, 0xc4, 0x16, 0x07,
  481. 0xdf, 0x33, 0xa0, 0x3f, 0x2a, 0x74, 0xf1, 0xb3, 0xdd, 0x6f, 0xfd,
  482. 0x90, 0xd5, 0xc1, 0x3a, 0x05, 0x47, 0x5b, 0x2a, 0x9f, 0x5a, 0xc6,
  483. 0xc0, 0xff, 0xb3, 0x16, 0xda, 0xf8, 0xe3, 0x17, 0xfb, 0xb6, 0x10,
  484. 0x97, 0xbc, 0x61, 0x12, 0x88, 0x26, 0x7a, 0x1d, 0x2c, 0xe4, 0x8d,
  485. 0xc0, 0xf7, 0xf4, 0x88, 0x29, 0xa3, 0xd4, 0x77, 0x5a, 0x22, 0x6e,
  486. 0x4d, 0xd8, 0xd9, 0x75, 0x93, 0xfe, 0xbf, 0xf4, 0xcc, 0x25, 0x63,
  487. 0xab, 0x63, 0x9f, 0x88, 0x62, 0x9e, 0xb1, 0x0d, 0xfe, 0x93, 0xa2,
  488. 0x0b, 0x57, 0x22, 0xff, 0x50, 0x03, 0x99, 0x3a, 0xb8, 0x2f, 0xdb,
  489. 0xa9, 0x8b, 0x53, 0xda, 0x8b, 0x1e, 0x75, 0xcc, 0x3f, 0x18, 0xa7,
  490. 0xba, 0xb7, 0x4b, 0x13, 0xa0, 0x66, 0xa1, 0x54, 0xd0, 0x42, 0xc5,
  491. 0x54, 0xff, 0xd7, 0x1e, 0x89, 0x26, 0xdb, 0xbf, 0x2d, 0xd6, 0x61,
  492. 0x3d, 0x87, 0x10, 0xf0, 0x91, 0xea, 0x6f, 0xed, 0x78, 0x01, 0x75,
  493. 0xaf, 0x2e, 0x6a, 0x65, 0xb3, 0xc1, 0x2a, 0x00, 0x00, 0x01, 0x00,
  494. 0x62, 0x5d, 0x9b, 0x8e, 0x20, 0xa3, 0x20, 0x1e, 0xbc, 0xf8, 0x33,
  495. 0x6e, 0x46, 0x0b, 0x5f, 0x96, 0xf5, 0x64, 0xd3, 0x49, 0xce, 0x1f,
  496. 0x77, 0x58, 0x5d, 0x2b, 0x25, 0xc0, 0xa2, 0x05, 0x4e, 0x2b, 0xd8,
  497. 0x0d, 0xcc, 0xe3, 0xcf, 0x4b, 0x29, 0x95, 0xa2, 0xec, 0x12, 0x1a,
  498. 0xdd, 0x4d, 0x18, 0x8e, 0x5f, 0x25, 0x6c, 0x08, 0x40, 0xe1, 0x62,
  499. 0xd9, 0x6f, 0x5a, 0x54, 0xf0, 0xdf, 0x8a, 0xe0, 0xb3, 0x64, 0x28,
  500. 0xba, 0xda, 0x6a, 0x21, 0x23, 0xa2, 0xab, 0x6e, 0x97, 0xc0, 0xf7,
  501. 0x4e, 0x95, 0xe8, 0xc3, 0xec, 0x7c, 0xbb, 0x82, 0xdc, 0x37, 0xc9,
  502. 0x1c, 0xab, 0x85, 0xb5, 0xc7, 0x60, 0x71, 0x34, 0x9c, 0xeb, 0xf1,
  503. 0xd3, 0xf4, 0x8f, 0xee, 0x29, 0x78, 0xb9, 0xbf, 0xff, 0x41, 0x14,
  504. 0xdd, 0xed, 0xc5, 0x0f, 0x6a, 0x8d, 0x9f, 0xdf, 0x9f, 0x5c, 0x1a,
  505. 0x96, 0xa9, 0xf3, 0x86, 0xa7, 0xa8, 0xa2, 0x63, 0x17, 0x79, 0xb8,
  506. 0xa1, 0x11, 0x9d, 0x64, 0x68, 0x53, 0x01, 0x03, 0xea, 0xb4, 0x63,
  507. 0x24, 0x72, 0x16, 0x6f, 0x22, 0xd2, 0xb2, 0x65, 0xee, 0xa9, 0x27,
  508. 0xd1, 0xe1, 0xb0, 0x4e, 0xe1, 0x34, 0xcb, 0x31, 0x3c, 0x70, 0x14,
  509. 0xa2, 0x7f, 0x10, 0xc0, 0xd2, 0xf5, 0xbf, 0xe2, 0x64, 0x1e, 0x0e,
  510. 0xe2, 0xf8, 0xe7, 0xbc, 0xac, 0x46, 0x71, 0xff, 0x9d, 0x66, 0xfe,
  511. 0xa1, 0x95, 0xb5, 0x72, 0xcd, 0xfb, 0x3f, 0x3c, 0xe6, 0x5b, 0x2a,
  512. 0xce, 0xec, 0x1e, 0xf4, 0xa8, 0x58, 0xe4, 0x8f, 0x02, 0x0b, 0x77,
  513. 0xfc, 0x9d, 0x1f, 0x8c, 0x8a, 0xf7, 0xe9, 0xd5, 0xc7, 0xbd, 0xa5,
  514. 0x23, 0x0a, 0x0a, 0x97, 0x51, 0x01, 0x2c, 0xce, 0x06, 0xec, 0xa4,
  515. 0x64, 0xa6, 0x19, 0x9a, 0x7b, 0x3a, 0x48, 0x0d, 0x14, 0xa8, 0x0a,
  516. 0x7b, 0x64, 0xb0, 0xca, 0xb9, 0xb6, 0xe1, 0x93, 0xd6, 0x4b, 0x57,
  517. 0x20, 0x0e, 0x74,
  518. ]),
  519. publicOrig: new Buffer([
  520. 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20,
  521. 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d,
  522. 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x44, 0x4f, 0x6a,
  523. 0x43, 0x43, 0x41, 0x69, 0x30, 0x47, 0x42, 0x79, 0x71, 0x47, 0x53,
  524. 0x4d, 0x34, 0x34, 0x42, 0x41, 0x45, 0x77, 0x67, 0x67, 0x49, 0x67,
  525. 0x41, 0x6f, 0x49, 0x42, 0x41, 0x51, 0x43, 0x64, 0x42, 0x72, 0x59,
  526. 0x66, 0x53, 0x52, 0x38, 0x50, 0x32, 0x76, 0x45, 0x5a, 0x6d, 0x4e,
  527. 0x32, 0x4e, 0x46, 0x42, 0x61, 0x67, 0x56, 0x6c, 0x56, 0x70, 0x4d,
  528. 0x31, 0x73, 0x5a, 0x0a, 0x4d, 0x78, 0x76, 0x67, 0x30, 0x64, 0x71,
  529. 0x4b, 0x68, 0x38, 0x45, 0x79, 0x4b, 0x6f, 0x77, 0x49, 0x76, 0x56,
  530. 0x36, 0x39, 0x4f, 0x71, 0x45, 0x6d, 0x33, 0x5a, 0x6c, 0x33, 0x64,
  531. 0x79, 0x5a, 0x64, 0x32, 0x78, 0x37, 0x47, 0x33, 0x64, 0x6f, 0x46,
  532. 0x61, 0x75, 0x50, 0x76, 0x34, 0x39, 0x39, 0x72, 0x4e, 0x4c, 0x69,
  533. 0x48, 0x2b, 0x68, 0x52, 0x46, 0x75, 0x35, 0x68, 0x61, 0x4b, 0x45,
  534. 0x6f, 0x67, 0x0a, 0x7a, 0x6e, 0x45, 0x56, 0x67, 0x45, 0x53, 0x55,
  535. 0x67, 0x41, 0x4a, 0x70, 0x43, 0x45, 0x2f, 0x58, 0x71, 0x66, 0x2f,
  536. 0x32, 0x6f, 0x50, 0x6f, 0x44, 0x56, 0x4a, 0x73, 0x49, 0x62, 0x54,
  537. 0x33, 0x6d, 0x35, 0x59, 0x67, 0x71, 0x6e, 0x41, 0x4a, 0x2f, 0x56,
  538. 0x56, 0x68, 0x4f, 0x38, 0x4b, 0x74, 0x72, 0x39, 0x42, 0x53, 0x62,
  539. 0x42, 0x74, 0x37, 0x61, 0x78, 0x56, 0x76, 0x36, 0x62, 0x34, 0x76,
  540. 0x34, 0x0a, 0x56, 0x62, 0x41, 0x54, 0x71, 0x35, 0x4d, 0x2b, 0x45,
  541. 0x49, 0x6e, 0x71, 0x6d, 0x79, 0x6d, 0x38, 0x44, 0x63, 0x47, 0x58,
  542. 0x50, 0x7a, 0x43, 0x50, 0x6f, 0x66, 0x53, 0x67, 0x45, 0x44, 0x31,
  543. 0x65, 0x37, 0x56, 0x6a, 0x64, 0x73, 0x75, 0x57, 0x68, 0x74, 0x34,
  544. 0x35, 0x56, 0x51, 0x2f, 0x54, 0x78, 0x45, 0x63, 0x6e, 0x68, 0x54,
  545. 0x35, 0x5a, 0x6d, 0x4a, 0x41, 0x39, 0x54, 0x2f, 0x69, 0x4b, 0x73,
  546. 0x0a, 0x72, 0x63, 0x62, 0x79, 0x39, 0x37, 0x59, 0x56, 0x42, 0x53,
  547. 0x6e, 0x71, 0x37, 0x6a, 0x66, 0x4d, 0x50, 0x6f, 0x59, 0x79, 0x69,
  548. 0x42, 0x68, 0x71, 0x4a, 0x78, 0x48, 0x46, 0x63, 0x31, 0x6b, 0x53,
  549. 0x66, 0x56, 0x46, 0x41, 0x55, 0x4b, 0x67, 0x47, 0x6a, 0x54, 0x52,
  550. 0x2b, 0x50, 0x2f, 0x5a, 0x73, 0x33, 0x6e, 0x61, 0x55, 0x76, 0x41,
  551. 0x6f, 0x72, 0x33, 0x35, 0x31, 0x4c, 0x37, 0x43, 0x4d, 0x50, 0x0a,
  552. 0x61, 0x30, 0x6b, 0x77, 0x65, 0x44, 0x66, 0x6c, 0x6e, 0x2b, 0x39,
  553. 0x49, 0x32, 0x2b, 0x6d, 0x74, 0x71, 0x67, 0x39, 0x5a, 0x68, 0x37,
  554. 0x4e, 0x51, 0x36, 0x6a, 0x70, 0x46, 0x39, 0x64, 0x2b, 0x6c, 0x44,
  555. 0x70, 0x2b, 0x52, 0x35, 0x42, 0x5a, 0x58, 0x51, 0x5a, 0x35, 0x38,
  556. 0x74, 0x44, 0x55, 0x70, 0x70, 0x55, 0x66, 0x79, 0x33, 0x73, 0x45,
  557. 0x4a, 0x41, 0x68, 0x55, 0x41, 0x79, 0x37, 0x33, 0x69, 0x0a, 0x51,
  558. 0x38, 0x38, 0x78, 0x48, 0x51, 0x54, 0x44, 0x70, 0x6d, 0x47, 0x59,
  559. 0x43, 0x67, 0x6b, 0x6c, 0x7a, 0x52, 0x47, 0x4f, 0x4b, 0x77, 0x45,
  560. 0x43, 0x67, 0x67, 0x45, 0x41, 0x61, 0x51, 0x35, 0x54, 0x39, 0x76,
  561. 0x38, 0x6a, 0x53, 0x69, 0x6b, 0x59, 0x68, 0x4d, 0x59, 0x4c, 0x48,
  562. 0x32, 0x6f, 0x55, 0x52, 0x79, 0x71, 0x49, 0x6e, 0x39, 0x55, 0x6b,
  563. 0x64, 0x57, 0x78, 0x69, 0x46, 0x43, 0x41, 0x7a, 0x0a, 0x2b, 0x4d,
  564. 0x4b, 0x54, 0x4a, 0x30, 0x52, 0x7a, 0x32, 0x52, 0x62, 0x4b, 0x4e,
  565. 0x6a, 0x37, 0x41, 0x71, 0x36, 0x55, 0x5a, 0x61, 0x6d, 0x59, 0x44,
  566. 0x7a, 0x41, 0x61, 0x5a, 0x69, 0x62, 0x32, 0x50, 0x67, 0x67, 0x43,
  567. 0x41, 0x77, 0x59, 0x52, 0x65, 0x4d, 0x46, 0x48, 0x78, 0x33, 0x4a,
  568. 0x67, 0x6b, 0x31, 0x6c, 0x56, 0x63, 0x72, 0x51, 0x6b, 0x34, 0x6d,
  569. 0x5a, 0x61, 0x75, 0x70, 0x53, 0x50, 0x6c, 0x0a, 0x44, 0x55, 0x59,
  570. 0x4a, 0x52, 0x4c, 0x6d, 0x45, 0x4c, 0x4a, 0x53, 0x49, 0x44, 0x75,
  571. 0x65, 0x5a, 0x56, 0x44, 0x69, 0x7a, 0x4b, 0x45, 0x59, 0x54, 0x6a,
  572. 0x31, 0x6f, 0x55, 0x45, 0x73, 0x56, 0x33, 0x49, 0x70, 0x4c, 0x71,
  573. 0x33, 0x76, 0x2f, 0x2b, 0x7a, 0x41, 0x51, 0x51, 0x52, 0x58, 0x37,
  574. 0x6f, 0x66, 0x44, 0x32, 0x70, 0x78, 0x42, 0x59, 0x48, 0x33, 0x7a,
  575. 0x4f, 0x67, 0x50, 0x79, 0x70, 0x30, 0x0a, 0x38, 0x62, 0x50, 0x64,
  576. 0x62, 0x2f, 0x32, 0x51, 0x31, 0x63, 0x45, 0x36, 0x42, 0x55, 0x64,
  577. 0x62, 0x4b, 0x70, 0x39, 0x61, 0x78, 0x73, 0x44, 0x2f, 0x73, 0x78,
  578. 0x62, 0x61, 0x2b, 0x4f, 0x4d, 0x58, 0x2b, 0x37, 0x59, 0x51, 0x6c,
  579. 0x37, 0x78, 0x68, 0x45, 0x6f, 0x67, 0x6d, 0x65, 0x68, 0x30, 0x73,
  580. 0x35, 0x49, 0x33, 0x41, 0x39, 0x2f, 0x53, 0x49, 0x4b, 0x61, 0x50,
  581. 0x55, 0x64, 0x31, 0x6f, 0x69, 0x0a, 0x62, 0x6b, 0x33, 0x59, 0x32,
  582. 0x58, 0x57, 0x54, 0x2f, 0x72, 0x2f, 0x30, 0x7a, 0x43, 0x56, 0x6a,
  583. 0x71, 0x32, 0x4f, 0x66, 0x69, 0x47, 0x4b, 0x65, 0x73, 0x51, 0x33,
  584. 0x2b, 0x6b, 0x36, 0x49, 0x4c, 0x56, 0x79, 0x4c, 0x2f, 0x55, 0x41,
  585. 0x4f, 0x5a, 0x4f, 0x72, 0x67, 0x76, 0x32, 0x36, 0x6d, 0x4c, 0x55,
  586. 0x39, 0x71, 0x4c, 0x48, 0x6e, 0x58, 0x4d, 0x50, 0x78, 0x69, 0x6e,
  587. 0x75, 0x72, 0x64, 0x4c, 0x0a, 0x45, 0x36, 0x42, 0x6d, 0x6f, 0x56,
  588. 0x54, 0x51, 0x51, 0x73, 0x56, 0x55, 0x2f, 0x39, 0x63, 0x65, 0x69,
  589. 0x53, 0x62, 0x62, 0x76, 0x79, 0x33, 0x57, 0x59, 0x54, 0x32, 0x48,
  590. 0x45, 0x50, 0x43, 0x52, 0x36, 0x6d, 0x2f, 0x74, 0x65, 0x41, 0x46,
  591. 0x31, 0x72, 0x79, 0x35, 0x71, 0x5a, 0x62, 0x50, 0x42, 0x4b, 0x67,
  592. 0x4f, 0x43, 0x41, 0x51, 0x55, 0x41, 0x41, 0x6f, 0x49, 0x42, 0x41,
  593. 0x47, 0x4a, 0x64, 0x0a, 0x6d, 0x34, 0x34, 0x67, 0x6f, 0x79, 0x41,
  594. 0x65, 0x76, 0x50, 0x67, 0x7a, 0x62, 0x6b, 0x59, 0x4c, 0x58, 0x35,
  595. 0x62, 0x31, 0x5a, 0x4e, 0x4e, 0x4a, 0x7a, 0x68, 0x39, 0x33, 0x57,
  596. 0x46, 0x30, 0x72, 0x4a, 0x63, 0x43, 0x69, 0x42, 0x55, 0x34, 0x72,
  597. 0x32, 0x41, 0x33, 0x4d, 0x34, 0x38, 0x39, 0x4c, 0x4b, 0x5a, 0x57,
  598. 0x69, 0x37, 0x42, 0x49, 0x61, 0x33, 0x55, 0x30, 0x59, 0x6a, 0x6c,
  599. 0x38, 0x6c, 0x0a, 0x62, 0x41, 0x68, 0x41, 0x34, 0x57, 0x4c, 0x5a,
  600. 0x62, 0x31, 0x70, 0x55, 0x38, 0x4e, 0x2b, 0x4b, 0x34, 0x4c, 0x4e,
  601. 0x6b, 0x4b, 0x4c, 0x72, 0x61, 0x61, 0x69, 0x45, 0x6a, 0x6f, 0x71,
  602. 0x74, 0x75, 0x6c, 0x38, 0x44, 0x33, 0x54, 0x70, 0x58, 0x6f, 0x77,
  603. 0x2b, 0x78, 0x38, 0x75, 0x34, 0x4c, 0x63, 0x4e, 0x38, 0x6b, 0x63,
  604. 0x71, 0x34, 0x57, 0x31, 0x78, 0x32, 0x42, 0x78, 0x4e, 0x4a, 0x7a,
  605. 0x72, 0x0a, 0x38, 0x64, 0x50, 0x30, 0x6a, 0x2b, 0x34, 0x70, 0x65,
  606. 0x4c, 0x6d, 0x2f, 0x2f, 0x30, 0x45, 0x55, 0x33, 0x65, 0x33, 0x46,
  607. 0x44, 0x32, 0x71, 0x4e, 0x6e, 0x39, 0x2b, 0x66, 0x58, 0x42, 0x71,
  608. 0x57, 0x71, 0x66, 0x4f, 0x47, 0x70, 0x36, 0x69, 0x69, 0x59, 0x78,
  609. 0x64, 0x35, 0x75, 0x4b, 0x45, 0x52, 0x6e, 0x57, 0x52, 0x6f, 0x55,
  610. 0x77, 0x45, 0x44, 0x36, 0x72, 0x52, 0x6a, 0x4a, 0x48, 0x49, 0x57,
  611. 0x0a, 0x62, 0x79, 0x4c, 0x53, 0x73, 0x6d, 0x58, 0x75, 0x71, 0x53,
  612. 0x66, 0x52, 0x34, 0x62, 0x42, 0x4f, 0x34, 0x54, 0x54, 0x4c, 0x4d,
  613. 0x54, 0x78, 0x77, 0x46, 0x4b, 0x4a, 0x2f, 0x45, 0x4d, 0x44, 0x53,
  614. 0x39, 0x62, 0x2f, 0x69, 0x5a, 0x42, 0x34, 0x4f, 0x34, 0x76, 0x6a,
  615. 0x6e, 0x76, 0x4b, 0x78, 0x47, 0x63, 0x66, 0x2b, 0x64, 0x5a, 0x76,
  616. 0x36, 0x68, 0x6c, 0x62, 0x56, 0x79, 0x7a, 0x66, 0x73, 0x2f, 0x0a,
  617. 0x50, 0x4f, 0x5a, 0x62, 0x4b, 0x73, 0x37, 0x73, 0x48, 0x76, 0x53,
  618. 0x6f, 0x57, 0x4f, 0x53, 0x50, 0x41, 0x67, 0x74, 0x33, 0x2f, 0x4a,
  619. 0x30, 0x66, 0x6a, 0x49, 0x72, 0x33, 0x36, 0x64, 0x58, 0x48, 0x76,
  620. 0x61, 0x55, 0x6a, 0x43, 0x67, 0x71, 0x58, 0x55, 0x51, 0x45, 0x73,
  621. 0x7a, 0x67, 0x62, 0x73, 0x70, 0x47, 0x53, 0x6d, 0x47, 0x5a, 0x70,
  622. 0x37, 0x4f, 0x6b, 0x67, 0x4e, 0x46, 0x4b, 0x67, 0x4b, 0x0a, 0x65,
  623. 0x32, 0x53, 0x77, 0x79, 0x72, 0x6d, 0x32, 0x34, 0x5a, 0x50, 0x57,
  624. 0x53, 0x31, 0x63, 0x67, 0x44, 0x6e, 0x51, 0x3d, 0x0a, 0x2d, 0x2d,
  625. 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x50, 0x55, 0x42, 0x4c,
  626. 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
  627. ])
  628. }
  629. );
  630. next();
  631. });
  632. },
  633. what: 'Generate public key from parsed public key'
  634. },
  635. ];
  636. function next() {
  637. if (Array.isArray(process._events.exit))
  638. process._events.exit = process._events.exit[1];
  639. if (++t === tests.length)
  640. return;
  641. var v = tests[t];
  642. process.nextTick(function() {
  643. v.run.call(v);
  644. });
  645. }
  646. function makeMsg(what, msg) {
  647. return '[' + group + what + ']: ' + msg;
  648. }
  649. process.once('exit', function() {
  650. assert(t === tests.length,
  651. makeMsg('_exit',
  652. 'Only finished ' + t + '/' + tests.length + ' tests'));
  653. });
  654. next();