Skip to content
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

Cannot verify Argon variant i and d #16

Open
austinfelipe opened this issue Nov 13, 2024 · 0 comments · May be fixed by #17
Open

Cannot verify Argon variant i and d #16

austinfelipe opened this issue Nov 13, 2024 · 0 comments · May be fixed by #17

Comments

@austinfelipe
Copy link

Package version

9.0.5

Describe the bug

Hi!

While testing with Adonis, I noticed argon.verify doesn't work with variants i and d.

To reproduce I guess you can try running these two tests and they should fail:

test('should verify a precomputed hash for variant i', async ({ assert }) => {
    // Precomputed hash for "password"
    const hash =
      '$argon2i$v=19$m=4096,t=4,p=2$dHRHRnJrNXhMS3hGdXp2Sg$rjAqTHriWP3GhO5/ZYoxuKcXDks/02JLGld9uBTsUgc'

    const argon = new Argon({
      variant: 'i',
      iterations: 4,
      memory: 4096,
      parallelism: 2,
      version: 19,
      saltSize: 16,
    })

    assert.isTrue(await argon.verify(hash, 'password'))
  })

  test('should verify a precomputed hash for variant d', async ({ assert }) => {
    // Precomputed hash for "password"
    const hash =
      '$argon2d$v=19$m=4096,t=4,p=2$dHRHRnJrNXhMS3hGdXp2Sg$F4lQNEt3xXSCNwTOflBJPzSlNk9dN3h1+lizNakqEzs'

    const argon = new Argon({
      variant: 'd',
      iterations: 4,
      memory: 4096,
      parallelism: 2,
      version: 19,
      saltSize: 16,
    })

    assert.isTrue(await argon.verify(hash, 'password'))
  })

Result 👇

CleanShot 2024-11-13 at 14 34 48@2x

The problem seems to be the following code, where i should be 1 and d should be 0

   /**
   * Supported variants
   */
  #variants: { [K in ArgonVariants]: 0 | 1 | 2 } = {
    i: 0,
    d: 1,
    id: 2,
  }

Reproduction repo

No response

@austinfelipe austinfelipe linked a pull request Nov 13, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant