28
28
/**
29
29
* ASN1 object identifiers for hashes (See {@link http://tools.ietf.org/html/rfc4880#section-5.2.2})
30
30
*/
31
-
hash_headers = [];
31
+
var hash_headers = [];
32
32
hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04,
33
33
0x10
34
34
];
@@ -53,6 +53,25 @@ var crypto = require('./crypto.js'),
53
53
BigInteger = require('./public_key/jsbn.js'),
54
54
hash = require('./hash');
55
55
56
+
/**
57
+
* Create padding with secure random data
58
+
* @private
59
+
* @param {Integer} length Length of the padding in bytes
60
+
* @return {String} Padding as string
61
+
*/
62
+
function getPkcs1Padding(length) {
63
+
var result = '';
64
+
var randomByte;
65
+
while (result.length < length) {
66
+
randomByte = random.getSecureRandomOctet();
67
+
if (randomByte !== 0) {
68
+
result += String.fromCharCode(randomByte);
69
+
}
70
+
}
71
+
return result;
72
+
}
73
+
74
+
56
75
module.exports = {
57
76
eme: {
58
77
/**
@@ -67,9 +86,7 @@ module.exports = {
67
86
var result = "";
68
87
result += String.fromCharCode(0);
69
88
result += String.fromCharCode(2);
70
-
for (var i = 0; i < length - message.length - 3; i++) {
71
-
result += String.fromCharCode(random.getPseudoRandom(1, 255));
72
-
}
89
+
result += getPkcs1Padding(length - message.length - 3);
73
90
result += String.fromCharCode(0);
74
91
result += message;
75
92
return result;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4