Skip to content

Commit 9a39bb7

Browse files
author
Syed Rakib Al Hasan
committed
Use CRYPTO_BYTE_SIZE length from the central configuration
instead of specifying crypto byte size lengths individually in every script
1 parent ec927fc commit 9a39bb7

File tree

7 files changed

+9
-6
lines changed

7 files changed

+9
-6
lines changed

Diff for: LambdAuthChangePassword/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var dynamodb = new AWS.DynamoDB();
1010

1111
function computeHash(password, salt, fn) {
1212
// Bytesize
13-
var len = 128;
13+
var len = config.CRYPTO_BYTE_SIZE;
1414
var iterations = 4096;
1515

1616
if (3 == arguments.length) {

Diff for: LambdAuthCreateUser/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var ses = new AWS.SES();
1212

1313
function computeHash(password, salt, fn) {
1414
// Bytesize
15-
var len = 128;
15+
var len = config.CRYPTO_BYTE_SIZE;
1616
var iterations = 4096;
1717

1818
if (3 == arguments.length) {
@@ -32,7 +32,7 @@ function computeHash(password, salt, fn) {
3232

3333
function storeUser(email, password, salt, fn) {
3434
// Bytesize
35-
var len = 128;
35+
var len = config.CRYPTO_BYTE_SIZE;
3636
crypto.randomBytes(len, function(err, token) {
3737
if (err) return fn(err);
3838
token = token.toString('hex');

Diff for: LambdAuthLogin/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var cognitoidentity = new AWS.CognitoIdentity();
1111

1212
function computeHash(password, salt, fn) {
1313
// Bytesize
14-
var len = 128;
14+
var len = config.CRYPTO_BYTE_SIZE;
1515
var iterations = 4096;
1616

1717
if (3 == arguments.length) {

Diff for: LambdAuthLostPassword/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function getUser(email, fn) {
3131

3232
function storeLostToken(email, fn) {
3333
// Bytesize
34-
var len = 128;
34+
var len = config.CRYPTO_BYTE_SIZE;
3535
crypto.randomBytes(len, function(err, token) {
3636
if (err) return fn(err);
3737
token = token.toString('hex');

Diff for: LambdAuthResetPassword/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var dynamodb = new AWS.DynamoDB();
1010

1111
function computeHash(password, salt, fn) {
1212
// Bytesize
13-
var len = 128;
13+
var len = config.CRYPTO_BYTE_SIZE;
1414
var iterations = 4096;
1515

1616
if (3 == arguments.length) {

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The `init.sh` script requires a configured [AWS Command Line Interface (CLI)](ht
4545
- the AWS region (e.g. "eu-west-1")
4646
- the Amazon S3 bucket to use for the sample HTML pages
4747
- the Cache-Control: max-age value, in seconds, to use on Amazon S3 (e.g. if distributed by [Amazon CloudFront](http://aws.amazon.com/cloudfront/) or another CDN)
48+
- the cryptographically generated byte size: the length of the various randomly generated hashes / keys / tokens etc can be altered from here centrally. If you choose to use different lengths for the different strings generated by the different lambda functions, you can override this value in those particular lambda scripts individually as desired
4849
- the Amazon DynamoDB table to create/use
4950
- the Amazon Cognito identity pool name to create/use (the identity pool id is automatically overwritten if present in the config.json file)
5051
- the Developer Provider Name to use with Amazon Cognito
@@ -60,6 +61,7 @@ The `init.sh` script requires a configured [AWS Command Line Interface (CLI)](ht
6061
"REGION": "eu-west-1",
6162
"BUCKET": "bucket",
6263
"MAX_AGE": "10",
64+
"CRYPTO_BYTE_SIZE": 128,
6365
"DDB_TABLE": "LambdAuthUsers",
6466
"IDENTITY_POOL_NAME": "LambdAuth",
6567
"DEVELOPER_PROVIDER_NAME": "login.mycompany.myapp",

Diff for: config.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"REGION": "eu-west-1",
55
"BUCKET": "bucket",
66
"MAX_AGE": "10",
7+
"CRYPTO_BYTE_SIZE": 128,
78
"DDB_TABLE": "LambdAuthUsers",
89
"IDENTITY_POOL_NAME": "LambdAuth",
910
"DEVELOPER_PROVIDER_NAME": "login.mycompany.myapp",

0 commit comments

Comments
 (0)