santoshbt

santoshbt

Cloak issue - (UndefinedFunctionError) function :crypto.stream_init/3 is undefined or private

Hi All,

I have upgraded cloak version from 0.6.2 to {:cloak_ecto, “~> 1.0.0”}
Erlang/OTP 25 [erts-13.0.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]
Elixir 1.13.4 (compiled with Erlang/OTP 25)

Whenever I try to migrate the old data or try to access them via application, I always get this error

** (UndefinedFunctionError) function :crypto.stream_init/3 is undefined or private
    (crypto 5.1.1) :crypto.stream_init(:aes_ctr, {:ok, <<56, 138, 106, 17, 173, 175, 16, 175, 12, 85, 252, 249, 179, 209, 235, 182, 107, 31, 156, 93, 236, 143, 202, 221, 116, 65, 57, 95, 143, 79, 13, 188>>}, <<43, 125, 214, 253, 52, 165, 131, 44, 177, 202, 118, 147, 35, 5, 80, 209>>)
    (cloak 1.0.3) lib/cloak/ciphers/deprecated/aes_ctr.ex:39: Cloak.Ciphers.Deprecated.AES.CTR.decrypt/2
    (my_future_now 4.0.0) lib/cloak_ecto/type.ex:47: MyApp.Encrypted.Binary.load/1
    (ecto 3.8.4) lib/ecto/type.ex:918: Ecto.Type.process_loaders/3
    (ecto 3.8.4) lib/ecto/repo/queryable.ex:403: Ecto.Repo.Queryable.struct_load!/6

Function: &:erlang.apply/2

    Args: [#Function<5.122125288/1 in Cloak.Ecto.Migrator.migrate_schema_with_data/2>, [1]]
[error] Task #PID<0.817.0> started from #PID<0.95.0> terminating
** (UndefinedFunctionError) function :crypto.stream_init/3 is undefined or private
    (crypto 5.1.1) :crypto.stream_init(:aes_ctr, {:ok, <<56, 138, 106, 17, 173, 175, 16, 175, 12, 85, 252, 249, 179, 209, 235, 182, 107, 31, 156, 93, 236, 143, 202, 221, 116, 65, 57, 95, 143, 79, 13, 188>>}, <<225, 62, 249, 49, 101, 202, 45, 28, 221, 3, 238, 254, 112, 32, 115, 255>>)
    (cloak 1.0.3) lib/cloak/ciphers/deprecated/aes_ctr.ex:39: Cloak.Ciphers.Deprecated.AES.CTR.decrypt/2
    (my_future_now 4.0.0) lib/cloak_ecto/type.ex:47: MyApp.Encrypted.Binary.load/1
    (ecto 3.8.4) lib/ecto/type.ex:918: Ecto.Type.process_loaders/3

Please help me, how rto resolve this issue.

Marked As Solved

santoshbt

santoshbt

Even after downgrading OTP version to 23, I am facing the error “Cloak.EncryptedBinaryField.equal?/2 is undefined or private” while inserting. But getting the data is working fine. It looks like it does not move anywhere now.

I suspect by default it upgrades ecto and ecto_sql as well.
I will install them in specific and check.

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Have you tried the most recent release of cloak_ecto which is “~> 1.2” ? I ask because OTP 25 is relatively recent, perhaps it is not supported by the version of cloak you are trying?

al2o3cr

al2o3cr

The function that’s missing is from “the old API” of the crypto module, which was deprecated in OTP 23 and removed entirely in OTP 24. That version of cloak_ecto will not work on anything higher than OTP 23.

From the last couple posts in your previous thread on this issue, it sounded like migrating was going to be a lengthy, incremental process:

  • upgrade to cloak 0.7 and do the data migration
  • upgrade to 0.8 and 0.9 (minor config changes)
  • THEN upgrade to Ecto 3 + 1.0, because of the changes in the type conversion machinery
  • upgrade to 1.1 to get the fix for the functions removed in OTP 24
benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@santoshbt the stream_init issue is because your moved to OTP 25 too fast. You’ll need to use OTP 23 until you finish the cloak upgrade, then you can switch to OTP 25.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&amp;query=perfume&amp;page=2, I would like to get: ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52774 488
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement