1 |
3a515b92
|
cagy
|
'use strict'
|
2 |
|
|
|
3 |
|
|
exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')
|
4 |
|
|
exports.createHash = exports.Hash = require('create-hash')
|
5 |
|
|
exports.createHmac = exports.Hmac = require('create-hmac')
|
6 |
|
|
|
7 |
|
|
var algos = require('browserify-sign/algos')
|
8 |
|
|
var algoKeys = Object.keys(algos)
|
9 |
|
|
var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
|
10 |
|
|
exports.getHashes = function () {
|
11 |
|
|
return hashes
|
12 |
|
|
}
|
13 |
|
|
|
14 |
|
|
var p = require('pbkdf2')
|
15 |
|
|
exports.pbkdf2 = p.pbkdf2
|
16 |
|
|
exports.pbkdf2Sync = p.pbkdf2Sync
|
17 |
|
|
|
18 |
|
|
var aes = require('browserify-cipher')
|
19 |
|
|
|
20 |
|
|
exports.Cipher = aes.Cipher
|
21 |
|
|
exports.createCipher = aes.createCipher
|
22 |
|
|
exports.Cipheriv = aes.Cipheriv
|
23 |
|
|
exports.createCipheriv = aes.createCipheriv
|
24 |
|
|
exports.Decipher = aes.Decipher
|
25 |
|
|
exports.createDecipher = aes.createDecipher
|
26 |
|
|
exports.Decipheriv = aes.Decipheriv
|
27 |
|
|
exports.createDecipheriv = aes.createDecipheriv
|
28 |
|
|
exports.getCiphers = aes.getCiphers
|
29 |
|
|
exports.listCiphers = aes.listCiphers
|
30 |
|
|
|
31 |
|
|
var dh = require('diffie-hellman')
|
32 |
|
|
|
33 |
|
|
exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
|
34 |
|
|
exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
|
35 |
|
|
exports.getDiffieHellman = dh.getDiffieHellman
|
36 |
|
|
exports.createDiffieHellman = dh.createDiffieHellman
|
37 |
|
|
exports.DiffieHellman = dh.DiffieHellman
|
38 |
|
|
|
39 |
|
|
var sign = require('browserify-sign')
|
40 |
|
|
|
41 |
|
|
exports.createSign = sign.createSign
|
42 |
|
|
exports.Sign = sign.Sign
|
43 |
|
|
exports.createVerify = sign.createVerify
|
44 |
|
|
exports.Verify = sign.Verify
|
45 |
|
|
|
46 |
|
|
exports.createECDH = require('create-ecdh')
|
47 |
|
|
|
48 |
|
|
var publicEncrypt = require('public-encrypt')
|
49 |
|
|
|
50 |
|
|
exports.publicEncrypt = publicEncrypt.publicEncrypt
|
51 |
|
|
exports.privateEncrypt = publicEncrypt.privateEncrypt
|
52 |
|
|
exports.publicDecrypt = publicEncrypt.publicDecrypt
|
53 |
|
|
exports.privateDecrypt = publicEncrypt.privateDecrypt
|
54 |
|
|
|
55 |
|
|
// the least I can do is make error messages for the rest of the node.js/crypto api.
|
56 |
|
|
// ;[
|
57 |
|
|
// 'createCredentials'
|
58 |
|
|
// ].forEach(function (name) {
|
59 |
|
|
// exports[name] = function () {
|
60 |
|
|
// throw new Error([
|
61 |
|
|
// 'sorry, ' + name + ' is not implemented yet',
|
62 |
|
|
// 'we accept pull requests',
|
63 |
|
|
// 'https://github.com/crypto-browserify/crypto-browserify'
|
64 |
|
|
// ].join('\n'))
|
65 |
|
|
// }
|
66 |
|
|
// })
|
67 |
|
|
|
68 |
|
|
var rf = require('randomfill')
|
69 |
|
|
|
70 |
|
|
exports.randomFill = rf.randomFill
|
71 |
|
|
exports.randomFillSync = rf.randomFillSync
|
72 |
|
|
|
73 |
|
|
exports.createCredentials = function () {
|
74 |
|
|
throw new Error([
|
75 |
|
|
'sorry, createCredentials is not implemented yet',
|
76 |
|
|
'we accept pull requests',
|
77 |
|
|
'https://github.com/crypto-browserify/crypto-browserify'
|
78 |
|
|
].join('\n'))
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
exports.constants = {
|
82 |
|
|
'DH_CHECK_P_NOT_SAFE_PRIME': 2,
|
83 |
|
|
'DH_CHECK_P_NOT_PRIME': 1,
|
84 |
|
|
'DH_UNABLE_TO_CHECK_GENERATOR': 4,
|
85 |
|
|
'DH_NOT_SUITABLE_GENERATOR': 8,
|
86 |
|
|
'NPN_ENABLED': 1,
|
87 |
|
|
'ALPN_ENABLED': 1,
|
88 |
|
|
'RSA_PKCS1_PADDING': 1,
|
89 |
|
|
'RSA_SSLV23_PADDING': 2,
|
90 |
|
|
'RSA_NO_PADDING': 3,
|
91 |
|
|
'RSA_PKCS1_OAEP_PADDING': 4,
|
92 |
|
|
'RSA_X931_PADDING': 5,
|
93 |
|
|
'RSA_PKCS1_PSS_PADDING': 6,
|
94 |
|
|
'POINT_CONVERSION_COMPRESSED': 2,
|
95 |
|
|
'POINT_CONVERSION_UNCOMPRESSED': 4,
|
96 |
|
|
'POINT_CONVERSION_HYBRID': 6
|
97 |
|
|
}
|