Skip to content

Added AES encryption/decryption using native crypto #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Oct 21, 2020
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
95b5a89
add native AES file encryption
cbaker6 Jun 30, 2020
7ae60e4
removed update of package.json
cbaker6 Jun 30, 2020
e507825
update package.json
cbaker6 Jun 30, 2020
dad1e7c
update node in travis
cbaker6 Jun 30, 2020
d01aa1f
update node in travis
cbaker6 Jun 30, 2020
e6c8f9b
trying different verion of key and iv hash
cbaker6 Jun 30, 2020
f9893de
downgrading node to match minimal parse-server
cbaker6 Jun 30, 2020
74c7c9e
removed commented code
cbaker6 Jun 30, 2020
9af50d3
add random iv for each file instead of using constant. Also removed e…
cbaker6 Jun 30, 2020
db8a1a8
remove unneccesary files
cbaker6 Jun 30, 2020
c9f9db8
Use AES 256 GCM to detect file tampering
cbaker6 Jun 30, 2020
11c6f3c
remove codecov from package.json
cbaker6 Jun 30, 2020
9f4fd11
add repo field to get rid of npm install warning
cbaker6 Jun 30, 2020
fb7517f
Fix options
cbaker6 Jun 30, 2020
92013a4
switch secretKey to fileKey
cbaker6 Jul 1, 2020
6f2752e
switch secretKey to fileKey
cbaker6 Jul 1, 2020
d2fce74
added the ability to rotate fileKeys
cbaker6 Jul 1, 2020
b42d683
add syntax highlighting to readme
cbaker6 Jul 1, 2020
0d25c2c
bump version
cbaker6 Jul 1, 2020
f633f70
attempt to fix coverage
cbaker6 Jul 1, 2020
e07ec58
update testcase title
cbaker6 Jul 1, 2020
7f1784c
clean up unused vars
cbaker6 Jul 2, 2020
8939921
add directions for multiple instances of parse-server
cbaker6 Jul 2, 2020
75d6b8a
update readme
cbaker6 Jul 2, 2020
9ac405f
update file names in readme
cbaker6 Jul 2, 2020
0c4bf0d
add testcase for rotating key from oldKey to noKey leaving all files …
cbaker6 Jul 2, 2020
47c87e7
Add notice about previous versions of parse-server
cbaker6 Jul 2, 2020
07061b7
Update README.md
cbaker6 Jul 2, 2020
bd19045
Update README.md
cbaker6 Jul 2, 2020
51c2b51
Update README.md
cbaker6 Jul 2, 2020
01fdf22
Update README.md
cbaker6 Jul 2, 2020
4517087
make createFile and getFile use streams instead of putting whole file…
cbaker6 Jul 4, 2020
b68681c
Merge branch 'master' of https://github.com/netreconlab/parse-server-…
cbaker6 Jul 4, 2020
9646246
don't read file into memory while deleting
cbaker6 Jul 4, 2020
39f96d2
clean up code
cbaker6 Jul 4, 2020
fbcabf4
make more consistant with GridFS adapter
cbaker6 Jul 4, 2020
1d3ca24
fixed formatting
cbaker6 Jul 4, 2020
4c344ee
Update .travis.yml
cbaker6 Jul 5, 2020
a20a7a2
Remove unnecessary testcase
cbaker6 Jul 5, 2020
b649dde
Update secureFiles.spec.js
cbaker6 Jul 5, 2020
2390e59
add directions for dev server to readme
cbaker6 Oct 21, 2020
6b175fb
Revert version
cbaker6 Oct 21, 2020
5beb618
Update package.json
cbaker6 Oct 21, 2020
490dc75
Update .travis.yml
cbaker6 Oct 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed commented code
  • Loading branch information
cbaker6 committed Jun 30, 2020
commit 74c7c9e1357651a6965696d0e8a524f30d50a3c8
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function FileSystemAdapter(options) {
throw "Encrypt key not defined";
}
this._encrypt = true;
this._secretKey = crypto.createHash('sha256').update(String(options.secretKey)).digest('base64').substr(0, 32);//crypto.scryptSync(options.secretKey, 'salt', 32);
this._secretKey = crypto.createHash('sha256').update(String(options.secretKey)).digest('base64').substr(0, 32);
}
let filesSubDirectory = options.filesSubDirectory || '';
this._filesDir = filesSubDirectory;
Expand All @@ -38,7 +38,7 @@ FileSystemAdapter.prototype.createFile = function(filename, data) {
return reject(err);
}
if(this._encrypt === true){
const iv = crypto.createHash('sha256').update(String(this._secretKey)).digest('base64').substr(0, 16);//crypto.scryptSync(this._secretKey, 'salt', 16); // Initialization vector.
const iv = crypto.createHash('sha256').update(String(this._secretKey)).digest('base64').substr(0, 16);
const cipher = crypto.createCipheriv(algorithm, this._secretKey, iv);
const input = fs.createReadStream(filepath);
const output = fs.createWriteStream(filepath+'.enc');
Expand Down Expand Up @@ -90,7 +90,7 @@ FileSystemAdapter.prototype.getFileData = function(filename) {
return reject(err);
}
if(encrypt){
const iv = crypto.createHash('sha256').update(String(secretKey)).digest('base64').substr(0, 16);//crypto.scryptSync(secretKey, 'salt', 16);
const iv = crypto.createHash('sha256').update(String(secretKey)).digest('base64').substr(0, 16);
const decipher = crypto.createDecipheriv(algorithm, secretKey, iv);
resolve(Buffer.concat([decipher.update(data), decipher.final()]));
}
Expand Down