Skip to content

Add Digest::from_bytes#1495

Closed
ldufr wants to merge 1 commit intobriansmith:mainfrom
sig4all:b/digest-from-bytes
Closed

Add Digest::from_bytes#1495
ldufr wants to merge 1 commit intobriansmith:mainfrom
sig4all:b/digest-from-bytes

Conversation

@ldufr
Copy link
Copy Markdown

@ldufr ldufr commented May 14, 2022

Digest::from_bytes can be used to create a Digest structure from an external source, without any knowledge of the digested message.

This can be particularly useful in combination with MR #1493 to sign a digest on behalf of a user authenticated through other means without exposing the private key of the user.

`Digest::from_bytes` can be used to create a `Digest` structure from
an external source, without any knowledge of the digested message.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
@ldufr ldufr force-pushed the b/digest-from-bytes branch from be34e59 to ce1ca78 Compare May 14, 2022 12:20
@ldufr ldufr changed the title Added Digest::from_bytes Add Digest::from_bytes May 14, 2022
Comment thread src/digest.rs
return Err(crate::error::Unspecified);
}

const SIZE: usize = 512 / 8 / core::mem::size_of::<BigEndian<u64>>();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit dodgy and there is certainly a much better way. Do you have a recommendation?

@briansmith
Copy link
Copy Markdown
Owner

I'm not excited about this idea. The idea of Digest is that when you have a Digest, you are certain that the digest was computed from ourselves. That means that we know (could have known) the value that was digested. If you just have a bunch of bytes that happen to be the right length for the algorithm you are interested in, you don't know what value was digested.

What is the use case you're trying to address?

@ldufr
Copy link
Copy Markdown
Author

ldufr commented Sep 21, 2022

In my case, it's impractical to have the original message, because it can be 100s of MBs, on a different machine. Furthermore, I can't send the private key to the machine with the data, for security reasons.

The goal is to split the digesting of this message and the signing of the message, which can be done with this PR in combination with #1493.

Edit: I will confirm later today that's still my case. I realize now that this might have been an original assumption which was in fact incorrect.

@ldufr
Copy link
Copy Markdown
Author

ldufr commented Sep 21, 2022

I double checked and it was indeed an incorrect assumption, because the digest received doesn't need to be encrypted, but instead the digest of a "document" containing this digest. This mean that we still compute the digest ourselves.

Anyway, thanks for your time and have a nice day!

@ldufr ldufr closed this Sep 21, 2022
@ldufr ldufr deleted the b/digest-from-bytes branch March 21, 2023 05:23
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 this pull request may close these issues.

2 participants