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

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
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
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
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
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement