@doctormckay/steam-crypto
Advanced tools
Comparing version 0.0.1 to 1.0.0
59
index.js
@@ -1,41 +0,42 @@ | ||
var crypto = require('crypto'); | ||
var publicKey = require('fs').readFileSync(__dirname + '/public.pub'); | ||
var Crypto = require('crypto'); | ||
var g_PubkeySystem = require('fs').readFileSync(__dirname + '/system.pem'); | ||
exports.verifySignature = function(data, signature, algorithm) { | ||
var verify = crypto.createVerify(algorithm || "RSA-SHA1"); | ||
verify.update(data); | ||
verify.end(); | ||
return verify.verify(publicKey, signature); | ||
var verify = Crypto.createVerify(algorithm || "RSA-SHA1"); | ||
verify.update(data); | ||
verify.end(); | ||
return verify.verify(g_PubkeySystem, signature); | ||
}; | ||
exports.generateSessionKey = function() { | ||
var sessionKey = crypto.randomBytes(32); | ||
var cryptedSessionKey = crypto.publicEncrypt(publicKey, sessionKey); | ||
return { | ||
plain: sessionKey, | ||
encrypted: cryptedSessionKey | ||
}; | ||
var sessionKey = Crypto.randomBytes(32); | ||
var cryptedSessionKey = Crypto.publicEncrypt(g_PubkeySystem, sessionKey); | ||
return { | ||
plain: sessionKey, | ||
encrypted: cryptedSessionKey | ||
}; | ||
}; | ||
exports.symmetricEncrypt = function(input, key) { | ||
var iv = crypto.randomBytes(16); | ||
var aesIv = crypto.createCipheriv('aes-256-ecb', key, ''); | ||
aesIv.setAutoPadding(false); | ||
aesIv.end(iv); | ||
var aesData = crypto.createCipheriv('aes-256-cbc', key, iv); | ||
aesData.end(input); | ||
return Buffer.concat([aesIv.read(), aesData.read()]); | ||
var iv = Crypto.randomBytes(16); | ||
var aesIv = Crypto.createCipheriv('aes-256-ecb', key, ''); | ||
aesIv.setAutoPadding(false); | ||
aesIv.end(iv); | ||
var aesData = Crypto.createCipheriv('aes-256-cbc', key, iv); | ||
aesData.end(input); | ||
return Buffer.concat([aesIv.read(), aesData.read()]); | ||
}; | ||
exports.symmetricDecrypt = function(input, key) { | ||
var aesIv = crypto.createDecipheriv('aes-256-ecb', key, ''); | ||
aesIv.setAutoPadding(false); | ||
aesIv.end(input.slice(0, 16)); | ||
var aesData = crypto.createDecipheriv('aes-256-cbc', key, aesIv.read()); | ||
aesData.end(input.slice(16)); | ||
return aesData.read(); | ||
var aesIv = Crypto.createDecipheriv('aes-256-ecb', key, ''); | ||
aesIv.setAutoPadding(false); | ||
aesIv.end(input.slice(0, 16)); | ||
var aesData = Crypto.createDecipheriv('aes-256-cbc', key, aesIv.read()); | ||
aesData.end(input.slice(16)); | ||
return aesData.read(); | ||
}; |
{ | ||
"name": "@doctormckay/steam-crypto", | ||
"version": "0.0.1", | ||
"description": "Node.js implementation of Valve's crypto", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/seishun/node-steam-crypto.git" | ||
}, | ||
"keywords": [ | ||
"steam", | ||
"crypto" | ||
], | ||
"author": "Nikolai Vavilov <vvnicholas@gmail.com>", | ||
"license": "MIT" | ||
"name": "@doctormckay/steam-crypto", | ||
"version": "1.0.0", | ||
"description": "Node.js implementation of Valve's crypto", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DoctorMcKay/node-steam-crypto.git" | ||
}, | ||
"keywords": [ | ||
"steam", | ||
"crypto" | ||
], | ||
"author": { | ||
"name": "Alexander Corn", | ||
"email": "mckay@doctormckay.com", | ||
"url": "https://www.doctormckay.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Nikolai Vavilov", | ||
"email": "vvnicholas@gmail.com" | ||
} | ||
], | ||
"license": "MIT" | ||
} |
# node-steam-crypto | ||
Node.js implementation of Steam crypto. All keys and data are passed as Buffers. | ||
Node.js implementation of Steam crypto. All keys, data, and signatures are passed as Buffers. | ||
Fork of, and compatible with, [steam-crypto](https://www.npmjs.com/package/steam-crypto). | ||
## verifySignature(data, signature[, algorithm]) | ||
Verifies an RSA signature using the Steam system's public key. `data` and `signature` should both be Buffers. `algorithm` defaults to "RSA-SHA1". Returns `true` if the signature is valid, or `false` if not. | ||
Verifies an RSA signature using the Steam system's public key. `algorithm` defaults to "RSA-SHA1". Returns `true` if the signature is valid, or `false` if not. | ||
@@ -9,0 +11,0 @@ ## generateSessionKey() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4603
1
24