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

Crypto: use a rich object to represent a message digest (instead of list of bytes) #2875

Closed
DartBot opened this issue May 2, 2012 · 4 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.

Comments

@DartBot
Copy link

DartBot commented May 2, 2012

This issue was originally filed by [email protected]


In its current shape, the hash and HMAC functions in the crypto library return List<int> as a message digest. This has several deficiencies:

  1. If you want to print it, you need an extra function to convert it to string (see issue Please add toHexString to crypto lib #2839).
  2. If you want to compare it and use the hashes for passwords, you have to be very careful to avoid timing attacks (se http://codahale.com/a-lesson-in-timing-attacks/).

Therefore, I propose to use a rich object called Digest instead. It would look like this:

interface Digest {
  final List<int> bytes;

  // TODO operator equals, when implemented
  bool operator ==(Digest other);

  String toString();
}

I'm attaching a patch with complete implementation (necessary modifications to tests included). Note that if you accept this, it supersedes issue #2839.

Please note that I DON'T really understand crypto, so if you decide to accept this API change, proper crypto review is a good idea :-)


Attachment:
0001-represent-message-digest-as-a-rich-object-with-bette.patch (9.72 KB)

@madsager
Copy link
Contributor

madsager commented May 8, 2012

Added Area-Library, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 3, 2012

This comment was originally written by [email protected]


To increase likelihood of getting this applied (or at least considered), I'm attaching a new version of the patch that applies cleanly to current Dart tree.

I intentionally didn't remove the CryptoUtils.bytesToHex function, because it might be useful for other stuff too, not only for digests.


Attachment:
0001-represent-message-digest-as-a-rich-object-with-bette.patch (10.87 KB)

@lrhn
Copy link
Member

lrhn commented Apr 25, 2014

Removed Area-Library label.
Added Area-Pkg, Pkg-Crypto labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/core#177.

@DartBot DartBot closed this as completed Jun 5, 2015
@kevmoo kevmoo removed the triaged label Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.
Projects
None yet
Development

No branches or pull requests

4 participants