Skip to content

Commit

Permalink
feat: add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Jan 31, 2024
1 parent aaa7aad commit 6bdb8c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export class Crypto extends AsyncOptionalCreatable<CryptoOptions> {

private decryptV2(tokens: string[]): Optional<string> {
const tag = tokens[1];
// assume the iv is v2 length (12 bytes) when parsing.
const iv = tokens[0].substring(0, IV_BYTES.v2 * 2);
const secret = tokens[0].substring(IV_BYTES.v2 * 2, tokens[0].length);

Expand All @@ -381,6 +382,8 @@ export class Crypto extends AsyncOptionalCreatable<CryptoOptions> {
throw error;
};

// This happens when the iv is v1 length (6 bytes), and the key is v1 length.
// We re-parse the tokens for iv and secret based on that length.
if (this.v1KeyLength && err?.message === 'Unsupported state or unable to authenticate data') {
getCryptoLogger().debug('v2 decryption failed so trying v1 decryption');
try {
Expand Down

2 comments on commit 6bdb8c0

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 6bdb8c0 Previous: aaa7aad Ratio
Child logger creation 444207 ops/sec (±1.45%) 476865 ops/sec (±2.14%) 1.07
Logging a string on root logger 770242 ops/sec (±9.76%) 852529 ops/sec (±7.47%) 1.11
Logging an object on root logger 603930 ops/sec (±8.07%) 585079 ops/sec (±5.09%) 0.97
Logging an object with a message on root logger 10502 ops/sec (±202.15%) 7812 ops/sec (±204.25%) 0.74
Logging an object with a redacted prop on root logger 432051 ops/sec (±10.09%) 411029 ops/sec (±13.06%) 0.95
Logging a nested 3-level object on root logger 365527 ops/sec (±6.70%) 354011 ops/sec (±7.38%) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: 6bdb8c0 Previous: aaa7aad Ratio
Child logger creation 319005 ops/sec (±1.17%) 315736 ops/sec (±1.47%) 0.99
Logging a string on root logger 717108 ops/sec (±10.64%) 715035 ops/sec (±10.74%) 1.00
Logging an object on root logger 598140 ops/sec (±6.61%) 569940 ops/sec (±6.72%) 0.95
Logging an object with a message on root logger 11063 ops/sec (±189.64%) 11081 ops/sec (±189.50%) 1.00
Logging an object with a redacted prop on root logger 438791 ops/sec (±11.87%) 402242 ops/sec (±13.90%) 0.92
Logging a nested 3-level object on root logger 333295 ops/sec (±5.54%) 321498 ops/sec (±4.91%) 0.96

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.