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

ERROR: (ErlangError) Erlang error: {:badarg, {'aead.c', 90}, 'Unknown cipher'} #118

Closed
1 task
nelsonic opened this issue Oct 18, 2022 · 5 comments
Closed
1 task
Assignees
Labels
BLOCKED Core team's HIGHEST priority, blocking critical work chore priority-1 T1h technical

Comments

@nelsonic
Copy link
Member

nelsonic commented Oct 18, 2022

All tests pass on the latest PR #117 and main: GitHub Workflow Status

But when we try to use this in auth we get the following error:

https://github.com/dwyl/auth/actions/runs/3272492583/jobs/5383565807
image

** (ErlangError) Erlang error: {:badarg, {'aead.c', 90}, 'Unknown cipher'}
    (crypto 5.0.2) :crypto.aead_cipher_nif(:aes_256_gcm, "", 
    <<56, 213, 219, 54, 35, 244, 145, 76, 175, 240, 168, 207, 97, 17, 17, 22>>, 
    "admin@dwylauth.com", "AES256GCM", 16, true)
    (fields 2.10.1) lib/aes.ex:36: Fields.AES.encrypt/1
    (fields 2.10.1) lib/encrypted.ex:21: Fields.Encrypted.dump/1
    (ecto 3.7.2) lib/ecto/type.ex:915: Ecto.Type.process_dumpers/3
    (ecto 3.7.2) lib/ecto/repo/schema.ex:996: Ecto.Repo.Schema.dump_field!/6
    (ecto 3.7.2) lib/ecto/repo/schema.ex:1009: anonymous fn/6 in Ecto.Repo.Schema.dump_fields!/5
    (stdlib 3.15.1) maps.erl:410: :maps.fold_1/3
    (ecto 3.7.2) lib/ecto/repo/schema.ex:1007: Ecto.Repo.Schema.dump_fields!/5
Error: Process completed with exit code 1.

Need to fix this ASAP as it's preventing the auth -> groups PR dwyl/auth#231 from progressing. 🤦‍♂️

Todo

  • Fix this!!
@nelsonic nelsonic added chore T1h priority-1 technical BLOCKED Core team's HIGHEST priority, blocking critical work labels Oct 18, 2022
@nelsonic nelsonic self-assigned this Oct 18, 2022
@nelsonic
Copy link
Member Author

Sadly, this forum thread: https://elixirforum.com/t/unknown-cipher-when-encrypting-data/41076 aren't much use.
Reading on the code in https://github.com/ferd/hairnet ... ⌛

@nelsonic
Copy link
Member Author

crypto:crypto_one_time_aead(aes_256_gcm, Key, IV, Message, EncodedSeconds, ?TAG_BYTES, true). invoked on:
https://github.com/ferd/hairnet/blob/32b8e13a58338ecaa58176561c56ecb8e64a4b79/src/hairnet.erl#L117

The official docs for this: https://www.erlang.org/doc/man/crypto.html#crypto_one_time_aead-6 are basically useless ...

@nelsonic
Copy link
Member Author

Replacing :aes_256_gcm with :aes_gcm 🤞

even though:

iex> :aes_256_gcm in :crypto.supports(:ciphers)
true

@nelsonic
Copy link
Member Author

nelsonic commented Oct 18, 2022

Still getting the same error in auth: https://github.com/dwyl/auth/actions/runs/3274331114/jobs/5387710444#step:7:215
image

** (ErlangError) Erlang error: {:badarg, {'aead.c', 90}, 'Unknown cipher'}
    (crypto 5.0.2) :crypto.aead_cipher_nif(:aes_gcm, "", 
<<226, 122, 88, 155, 245, 35, 254, 89, 187, 55, 146, 130, 164, 206, 219, 44>>, 
"admin@dwylauth.com", "AES256GCM", 16, true)
    (fields 2.10.2) lib/aes.ex:38: Fields.AES.encrypt/1
    (fields 2.10.2) lib/encrypted.ex:21: Fields.Encrypted.dump/1
    (ecto 3.7.2) lib/ecto/type.ex:915: Ecto.Type.process_dumpers/3
    (ecto 3.7.2) lib/ecto/repo/schema.ex:996: Ecto.Repo.Schema.dump_field!/6
    (ecto 3.7.2) lib/ecto/repo/schema.ex:1009: anonymous fn/6 in Ecto.Repo.Schema.dump_fields!/5
    (stdlib 3.15.1) maps.erl:410: :maps.fold_1/3
    (ecto 3.7.2) lib/ecto/repo/schema.ex:1007: Ecto.Repo.Schema.dump_fields!/5
Error: Process completed with exit code 1.

Going to add a regression test here in fields for this now!!! 🤦‍♂️

nelsonic added a commit that referenced this issue Oct 18, 2022
nelsonic added a commit that referenced this issue Oct 18, 2022
@nelsonic
Copy link
Member Author

OK, I think this is fixed because we're no longer seeing any crypto/fields errors in Auth: dwyl/auth#231
Closing. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKED Core team's HIGHEST priority, blocking critical work chore priority-1 T1h technical
Projects
None yet
Development

No branches or pull requests

1 participant