Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Trac
Trac
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Issue Boards

GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

  • Legacy
  • TracTrac
  • Issues
  • #17796

Closed (moved)
Open
Opened Dec 09, 2015 by Nick Mathewson@nickm🐙

Make crypto_digest_t allocated using minimal memory

We will soon have:

struct crypto_digest_t {
  union {
    SHA_CTX sha1; 
    SHA256_CTX sha2; 
    SHA512_CTX sha512; // added in 0.2.8
    keccak_state sha3; // added by #17783
  } d; 
  digest_algorithm_bitfield_t algorithm : 8;
};

On my 64-bit host:

Size of SHA_CTX == 96
Size of SHA256_CTX == 112
Size of SHA512_CTX == 216
Size of keccak_state == 432

This means that when we allocate a sha1 digest object in order to compute the running SHA1 of an input stream (for the current tor relay protocol), we have been wasting 16 bytes, we are now wasting 120 bytes, and we will soon be wasting 336 bytes.

We should probably adjust the way we lay out and allocate the crypto_digest_t structure so that it looks more like this:

struct crypto_digest_t {
  digest_algorithm_t algorithm; // no point in a bitfield
  union {
    SHA_CTX sha1; 
    SHA256_CTX sha2; 
    SHA512_CTX sha512; // added in 0.2.8
    keccak_state sha3; // added by #17783
  } d; 

and we should have crypto_digest*_new allocate no more bytes than the algorithm will actually use.

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
Tor: 0.2.8.x-final
Milestone
Tor: 0.2.8.x-final
Assign milestone
Time tracking
None
Due date
None
Reference: legacy/trac#17796