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

secrecy: cannot clone SecretSlice #1233

Closed
tzilist opened this issue Oct 2, 2024 · 3 comments · Fixed by #1236
Closed

secrecy: cannot clone SecretSlice #1233

tzilist opened this issue Oct 2, 2024 · 3 comments · Fixed by #1236

Comments

@tzilist
Copy link

tzilist commented Oct 2, 2024

the new SecretSlice seems quite handly, however, with the recent changes to secrecy, there was removal of impl CloneableSecret on different array types (seemingly done here)

With that said, it is no longer possible to do something like SecretSlice<u8> as it now returns this error when attempting to implement clone

  --> iam/iam-api-key/src/model/api_key.rs:45:5
   |
39 | #[derive(Debug, Clone)]
   |                 ----- in this derive macro expansion
...
45 |     key: SecretSlice<u8>,
   |     ^^^^^^^^^^^^^^^^^^^^ the trait `secrecy::CloneableSecret` is not implemented for `[u8]`, which is required by `secrecy::SecretBox<[u8]>: std::clone::Clone`
   |
   = help: the following other types implement trait `secrecy::CloneableSecret`:
             model::api_key::KeyBytes
             model::api_key::encode::EncodedApiKey
   = note: required for `secrecy::SecretBox<[u8]>` to implement `std::clone::Clone`
   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
   

It is also not possible to do something like SecretBox<[u8; 32]> as it results in the same error.

Would it be possible to add these implementations back into secrecy for basic array types like this?

@tzilist
Copy link
Author

tzilist commented Oct 8, 2024

This looks like a duplicate of #1070

@tzilist tzilist closed this as completed Oct 8, 2024
@tony-iqlusion tony-iqlusion changed the title How to use SecretSlice Cannot close SecretSlice Oct 9, 2024
@tony-iqlusion
Copy link
Member

Moving to this issue because SecretVec from #1070 is now gone, and SecretSlice is the new type

@tony-iqlusion tony-iqlusion changed the title Cannot close SecretSlice secrecy: cannot clone SecretSlice Oct 9, 2024
@tony-iqlusion tony-iqlusion reopened this Oct 9, 2024
tony-iqlusion added a commit that referenced this issue Oct 9, 2024
Impls `Clone` for `SecretSlice` when the `S` generic type is
`CloneableSecret + Zeroize`.

As originally requested in #1070, also marks the integer primitive types
as `CloneableSecret`, which makes it possible to clone a
`SecretSlice<u8>`.

Closes #1233
@tony-iqlusion
Copy link
Member

Fix is #1236

tony-iqlusion added a commit that referenced this issue Oct 9, 2024
Impls `Clone` for `SecretSlice` when the `S` generic type is
`CloneableSecret + Zeroize`.

As originally requested in #1070, also marks the integer primitive types
as `CloneableSecret`, which makes it possible to clone a
`SecretSlice<u8>`.

Closes #1233
tony-iqlusion added a commit that referenced this issue Oct 9, 2024
Impls `Clone` for `SecretSlice` when the `S` generic type is
`CloneableSecret + Zeroize`.

As originally requested in #1070, also marks the integer primitive types
as `CloneableSecret`, which makes it possible to clone a
`SecretSlice<u8>`.

Closes #1233
tony-iqlusion added a commit that referenced this issue Oct 9, 2024
Impls `Clone` for `SecretSlice` when the `S` generic type is
`CloneableSecret + Zeroize`.

As originally requested in #1070, also marks the integer primitive types
as `CloneableSecret`, which makes it possible to clone a
`SecretSlice<u8>`.

Closes #1233
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.

2 participants