diff --git a/package-lock.json b/package-lock.json index f34991c0..a7d126c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4725,11 +4725,29 @@ "pend": "~1.2.0" } }, +<<<<<<< HEAD "figgy-pudding": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==", "dev": true +======= + "fernet": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/fernet/-/fernet-0.3.1.tgz", + "integrity": "sha512-7KnsrcpLkUsKy6aH6Ow68hrMWhvE25rTDd3370+xVGkpqZta05cUCmdJQPyLBKTsNdPUB5NumJZBgJIJ60aQqw==", + "requires": { + "crypto-js": "~3.1.2-1", + "urlsafe-base64": "1.0.0" + }, + "dependencies": { + "crypto-js": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.8.tgz", + "integrity": "sha1-cV8HC/YBTyrpkqmLOSkli3E/CNU=" + } + } +>>>>>>> Add Fernet encrypt/decrypt }, "figures": { "version": "2.0.0", @@ -12952,6 +12970,11 @@ "requires-port": "^1.0.0" } }, + "urlsafe-base64": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/urlsafe-base64/-/urlsafe-base64-1.0.0.tgz", + "integrity": "sha1-I/iQaabGL0bPOh07ABac77kL4MY=" + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", diff --git a/package.json b/package.json index 94c96357..2e2619ae 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "esmangle": "^1.0.1", "esprima": "^4.0.1", "exif-parser": "^0.1.12", + "fernet": "^0.3.1", "file-saver": "^2.0.0", "geodesy": "^1.1.3", "highlight.js": "^9.13.1", diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index 661e0f70..92a1e701 100755 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -73,6 +73,8 @@ "DES Decrypt", "Triple DES Encrypt", "Triple DES Decrypt", + "Fernet Encrypt", + "Fernet Decrypt", "RC2 Encrypt", "RC2 Decrypt", "RC4", diff --git a/src/core/operations/FernetDecrypt.mjs b/src/core/operations/FernetDecrypt.mjs new file mode 100644 index 00000000..f720b6c4 --- /dev/null +++ b/src/core/operations/FernetDecrypt.mjs @@ -0,0 +1,58 @@ +/** + * @author kassi [kassi@noreply.com] + * @copyright KS 2018 + * @license Apache-2.0 + */ + +import Operation from '../Operation'; + +/** + * FernetDecrypt operation + */ +class FernetDecrypt extends Operation { + /** + * FernetDecrypt constructor + */ + + constructor() { + super(); + + this.name = 'Fernet Decrypt'; + this.module = 'Default'; + this.description = 'Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().'; + this.infoURL = 'https://asecuritysite.com/encryption/fer'; + this.inputType = 'string'; + this.outputType = 'string'; + this.args = [ + { + 'name': 'Secret', + 'type': 'string', + 'value': "" + }, + ]; + this.patterns = [ + { + match: "^[A-Z\\d\\-_=]{20,}$", + flags: "i", + args: [] + }, + ]; + } + /** + * @param {String} input + * @param {Object[]} args + * @returns {String} + */ + run(input, args) { + const [secretInput] = args; + var fernet = require('fernet'); + var secret = new fernet.Secret(secretInput); + var token = new fernet.Token({ + secret: secret, + token: input + }) + return token.decode(); + } +} + +export default FernetDecrypt; diff --git a/src/core/operations/FernetEncrypt.mjs b/src/core/operations/FernetEncrypt.mjs new file mode 100644 index 00000000..f85bd3b1 --- /dev/null +++ b/src/core/operations/FernetEncrypt.mjs @@ -0,0 +1,50 @@ +/** + * @author kassi [kassi@noreply.com] + * @copyright KS 2018 + * @license Apache-2.0 + */ + +import Operation from '../Operation'; + +/** + * FernetEncrypt operation + */ +class FernetEncrypt extends Operation { + /** + * FernetEncrypt constructor + */ + + constructor() { + super(); + + this.name = 'Fernet Encrypt'; + this.module = 'Default'; + this.description = 'Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().'; + this.infoURL = 'https://asecuritysite.com/encryption/fer'; + this.inputType = 'string'; + this.outputType = 'string'; + this.args = [ + { + 'name': 'Secret', + 'type': 'string', + 'value': "" + }, + ]; + } + /** + * @param {String} input + * @param {Object[]} args + * @returns {String} + */ + run(input, args) { + const [secretInput] = args; + var fernet = require('fernet'); + var secret = new fernet.Secret(secretInput); + var token = new fernet.Token({ + secret: secret, + }) + return token.encode(input); + } +} + +export default FernetEncrypt;