Skip to content

Commit

Permalink
removendo logs de debug e subterfugios técnicos não mais necessários
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioconselheiro committed Feb 14, 2024
1 parent 64c5d65 commit 199094b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 48 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/core/jest-html-reporters-attach/test-report/result.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ciphers/aes/cbc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EncryptedURIAESCBCDecrypter extends EncryptedURIDecrypter<TInitializationV
const ivhex = getInitializationVector(this.decoded);
const cipher = base64.decode(this.decoded.cipher);
const params = getSalt(cipher, this.decoded?.params);
console.info(' >>> this.decoded: ', this.decoded);

const derivatedKey = kdf(this.password, params.salt, this.decoded);

const result = await cbc(derivatedKey, hexToBytes(ivhex))
Expand Down Expand Up @@ -48,7 +48,7 @@ class EncryptedURIAESCBCEncrypter extends EncryptedURIEncrypter<TInitializationV
const content = utf8ToBytes(this.params.content);
const saltLength = 8;
const salt = randomBytes(saltLength);
console.info(' >>> this.params: ', this.params);

const derivatedKey = kdf(this.params.password, salt, this.params);
const cipher = await cbc(derivatedKey, iv).encrypt(content);

Expand Down
2 changes: 0 additions & 2 deletions packages/ciphers/aes/kdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export function kdf<T extends TURIParams>(
kdfConfig?: TEncryptedURI<T> | TEncryptedURIResultset<T>
): Uint8Array {
const cfg = EncryptedURI.getKDFConfig(kdfConfig);
console.info(' >>> cfg: ', cfg);

const saltLength = 8;
if (salt.length !== saltLength) {
throw new Error(`salt length must be ${saltLength} bytes, ${salt.length} bytes was given`);
Expand Down
22 changes: 11 additions & 11 deletions packages/ciphers/kdf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('kdf success flow', () => {

it('[3] kdf with hasher sha512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha512' as any as 'sha256'
hasher: 'sha512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -48,7 +48,7 @@ describe('kdf success flow', () => {

it('[4] kdf with hasher sha512_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha512_256' as any as 'sha256'
hasher: 'sha512_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -67,7 +67,7 @@ describe('kdf success flow', () => {

it('[5] kdf with hasher sha384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha384' as any as 'sha256'
hasher: 'sha384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -86,7 +86,7 @@ describe('kdf success flow', () => {

it('[6] kdf with hasher sha3_512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_512' as any as 'sha256'
hasher: 'sha3_512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -105,7 +105,7 @@ describe('kdf success flow', () => {

it('[7] kdf with hasher sha3_384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_384' as any as 'sha256'
hasher: 'sha3_384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -124,7 +124,7 @@ describe('kdf success flow', () => {

it('[8] kdf with hasher sha3_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_256' as any as 'sha256'
hasher: 'sha3_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -143,7 +143,7 @@ describe('kdf success flow', () => {

it('[9] kdf with hasher sha3_224', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_224' as any as 'sha256'
hasher: 'sha3_224'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -162,7 +162,7 @@ describe('kdf success flow', () => {

it('[10] kdf with hasher keccak_512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_512' as any as 'sha256'
hasher: 'keccak_512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -181,7 +181,7 @@ describe('kdf success flow', () => {

it('[11] kdf with hasher keccak_384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_384' as any as 'sha256'
hasher: 'keccak_384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -200,7 +200,7 @@ describe('kdf success flow', () => {

it('[12] kdf with hasher keccak_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_256' as any as 'sha256'
hasher: 'keccak_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -219,7 +219,7 @@ describe('kdf success flow', () => {

it('[13] kdf with hasher keccak_224', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_224' as any as 'sha256'
hasher: 'keccak_224'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand Down
20 changes: 10 additions & 10 deletions packages/ciphers/params.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './hashes';
describe('hashing customization', () => {
it('[3] kdf with hasher sha512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha512' as any as 'sha256'
hasher: 'sha512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -28,7 +28,7 @@ describe('hashing customization', () => {

it('[4] kdf with hasher sha512_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha512_256' as any as 'sha256'
hasher: 'sha512_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -51,7 +51,7 @@ describe('hashing customization', () => {

it('[5] kdf with hasher sha384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha384' as any as 'sha256'
hasher: 'sha384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -74,7 +74,7 @@ describe('hashing customization', () => {

it('[6] kdf with hasher sha3_512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_512' as any as 'sha256'
hasher: 'sha3_512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -97,7 +97,7 @@ describe('hashing customization', () => {

it('[7] kdf with hasher sha3_384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_384' as any as 'sha256'
hasher: 'sha3_384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -120,7 +120,7 @@ describe('hashing customization', () => {

it('[8] kdf with hasher sha3_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_256' as any as 'sha256'
hasher: 'sha3_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -143,7 +143,7 @@ describe('hashing customization', () => {

it('[9] kdf with hasher sha3_224', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'sha3_224' as any as 'sha256'
hasher: 'sha3_224'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -166,7 +166,7 @@ describe('hashing customization', () => {

it('[10] kdf with hasher keccak_512', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_512' as any as 'sha256'
hasher: 'keccak_512'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -189,7 +189,7 @@ describe('hashing customization', () => {

it('[11] kdf with hasher keccak_384', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_384' as any as 'sha256'
hasher: 'keccak_384'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand All @@ -212,7 +212,7 @@ describe('hashing customization', () => {

it('[12] kdf with hasher keccak_256', async () => {
const kdf: TEncryptedURIKDFConfig = {
hasher: 'keccak_256' as any as 'sha256'
hasher: 'keccak_256'
};

const originalMessage = 'mensagem secreta, favor não ler em voz alta';
Expand Down
26 changes: 5 additions & 21 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@ export type TEncryptedURIKDFConfig = {
/**
* Hashing algorithm supported by pbkdf2
*
* I have tried to include more hashers, but they
* thrown exception and I don't understand why, If
* you need other hasher then sha256 to be able to
* be configured, you must help me opening a pull
* request with the solution and unit tests validating
* it, those are the hashers for kdf that I can't solve:
*
* sha512, sha512_256, sha384, sha3_512,
* sha3_384, sha3_256, sha3_224, keccak_512,
* keccak_384, keccak_256, keccak_224
*
* Issue:
* https://github.com/antonioconselheiro/encrypted-uri/issues/27
*
* @default sha256
*/
hasher?: string | 'sha256' | 'sha512'| 'sha512_256'| 'sha384'| 'sha3_512'| 'sha3_384'| 'sha3_256'| 'sha3_224'| 'keccak_512'| 'keccak_384'| 'keccak_256'| 'keccak_224';
Expand Down Expand Up @@ -140,13 +126,11 @@ class EncryptedURIDecoder<T extends TURIParams> {

if (typeof params.dklen === 'string') {
const derivateKeyLength = Number(params.dklen);
const fixedDerivateKeyLengthValue = 32;
if (Number.isSafeInteger(derivateKeyLength)
// remove this when implements this issue:
// https://github.com/antonioconselheiro/encrypted-uri/issues/27
&& derivateKeyLength === fixedDerivateKeyLengthValue
) {
config.derivateKeyLength = derivateKeyLength;
if (Number.isSafeInteger(derivateKeyLength)) {
// remove any quando issue for resolvido
// https://github.com/antonioconselheiro/encrypted-uri/issues/31
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config.derivateKeyLength = derivateKeyLength as any;
}
}

Expand Down

0 comments on commit 199094b

Please sign in to comment.