Skip to content
  • John McDole's avatar
    Add missing SHA224, SHA384, and SHA512 (#63) · a66bf909
    John McDole authored
    * Add SHA384 and SHA512
    
    Sha384 and Sha512 share the same implementation and differ only in the
    initailization vectors and the digest concatentation. The algorithm from
    from rfc6234 calls for 64bit words and operations and to remain dart2js
    friendly, BigInt was used.
    
    INPUT REQUESTED:
      I'm not sure where the test vectors came from; but a simple comparison
      to sha384 and sha512 command line methods shows it matching. If you
      can point me to them, then I can write a better test.
    
    * Add Sha224 + Refactor
    
    Do something less stupid; use _Sha32BitSink and _Sha64BitSink to have
    class heirarchies make better sense.
    
    * Support 32bit and 64bit operations for SHA384/512
    
    Two modes of operation: if you're in a browser, you get the slower 32bit
    algorithm because you only have 2^53 bits. If you are on the VM /
    Flutter, you'll have 64bit operations wich is *much* faster:
    
    32BIT NUMBERS: ~20MB/s hashing
    Removing BigInt has some good results:
      Instance of 'Sha224' warmup: 0:00:00.015599
      Instance of 'Sha256' warmup: 0:00:00.002325
      Instance of 'Sha384' warmup: 0:00:00.019082
      Instance of 'Sha512' warmup: 0:00:00.010288
      Instance of 'Sha224' real: 0:00:00.092928
      Instance of 'Sha256' real: 0:00:00.093426
      Instance of 'Sha384' real: 0:00:00.823335
      Instance of 'Sha512' real: 0:00:00.807871
    
    64BIT NUMBERS: ~236MB/s hashing
    On the VM, this is much faster with 64bit operations.
      Instance of 'Sha224' warmup: 0:00:00.013285
      Instance of 'Sha256' warmup: 0:00:00.002443
      Instance of 'Sha384' warmup: 0:00:00.020954
      Instance of 'Sha512' warmup: 0:00:00.005616
      Instance of 'Sha224' real: 0:00:00.097196
      Instance of 'Sha256' real: 0:00:00.094167
      Instance of 'Sha384' real: 0:00:00.067605
      Instance of 'Sha512' real: 0:00:00.067564
    
    NOTE:
    Compiles with dart2js - cannot reference 64bit hex as the compiler just
    vomits... but you can left shift by 32.
    
    * Fix comment
    
    * Add conditional imports
    
    * De-listify 32bit allocations
    
    Speed is still meh in dart2js:
    
    384/512 numbers:
    Instance of 'minified:a2' real: 0:00:02.203820
    Instance of 'minified:aO' real: 0:00:02.192515
    
    * Add sha monte tests for 224,256,384, and 512
    
    RSP values came from http://csrc.nist.gov/groups/STM/cavp/documents/shs/shabytetestvectors.zip
    
    * Fix formattting of lib/crypto.dart
    
    * Bump version (adding new features) + min sdk
    
    * Bump travis (hidden file)
    
    * Rework monte test to function-only.
    a66bf909
Loading