2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-13 08:46:33 +00:00
Commit Graph

42 Commits

Author SHA1 Message Date
Alexander Neumann
f8e1043ad3 crypto: Match signature of Encrypt() to Decrypt() 2015-04-12 20:58:41 +02:00
Alexander Neumann
64f7d4d611 crypto: Rename exported funcs and structs, cleanup 2015-04-12 10:55:56 +02:00
Alexander Neumann
21dc6dd3db Rename crypto functions and constants 2015-04-12 09:41:47 +02:00
Alexander Neumann
3a2525809c Reorganize crypto code
Move all crypto functions to package "crypto", move random generators
for tests into helper package.
2015-04-12 09:36:14 +02:00
Alexander Neumann
b2307cafa2 Seed chunker with random per-repository polynomial 2015-04-06 00:22:19 +02:00
Alexander Neumann
223108c6ae Remove unused vars and const 2015-03-28 15:28:08 +01:00
Alexander Neumann
f157f775da Add checks for Server.Load(), use Blob for load 2015-03-28 15:07:08 +01:00
Alexander Neumann
5e69788eac Refactor backends 2015-03-28 14:36:50 +01:00
Alexander Neumann
0ed2a066a0 Document crypto and master key JSON struct 2015-03-22 21:03:01 +01:00
Alexander Neumann
65a653693e Rename keys to MasterKeys 2015-03-22 19:19:33 +01:00
Alexander Neumann
664a12c950 Collect all master crypto keys in a single structure 2015-03-22 19:18:34 +01:00
Alexander Neumann
47d71d23d2 Refactor JSON data structure for master keys 2015-03-22 19:09:30 +01:00
Alexander Neumann
662e07d17a Refactor crypto layer, switch HMAC for Poyl1305-AES
HMAC-SHA256 calls SHA256() twice which is very expensive. Therefore,
this commit uses Poly1305-AES instead of HMAC-SHA256.

benchcmp:

     benchmark                         old ns/op      new ns/op      delta
     BenchmarkChunkEncrypt             261033772      195114818      -25.25%
     BenchmarkChunkEncryptParallel     260973195      195787368      -24.98%
     BenchmarkArchiveDirectory         1050500651     1002615884     -4.56%
     BenchmarkPreload                  23544286       24994508       +6.16%
     BenchmarkLoadTree                 350065         427665         +22.17%
     BenchmarkEncryptWriter            87789753       31069126       -64.61%
     BenchmarkEncrypt                  88283197       38259043       -56.66%
     BenchmarkDecryptReader            90478843       40714818       -55.00%
     BenchmarkEncryptDecryptReader     179917626      81231730       -54.85%
     BenchmarkDecrypt                  87871591       37784207       -57.00%
     BenchmarkSaveJSON                 52481          56861          +8.35%
     BenchmarkSaveFrom                 75404085       51108596       -32.22%
     BenchmarkLoadJSONID               90545437       82696805       -8.67%

     benchmark                         old MB/s     new MB/s     speedup
     BenchmarkChunkEncrypt             40.17        53.74        1.34x
     BenchmarkChunkEncryptParallel     40.18        53.56        1.33x
     BenchmarkEncryptWriter            95.55        270.00       2.83x
     BenchmarkEncrypt                  95.02        219.26       2.31x
     BenchmarkDecryptReader            92.71        206.03       2.22x
     BenchmarkEncryptDecryptReader     46.62        103.27       2.22x
     BenchmarkDecrypt                  95.46        222.01       2.33x
     BenchmarkSaveFrom                 55.62        82.07        1.48x

     benchmark                         old allocs     new allocs     delta
     BenchmarkChunkEncrypt             112            110            -1.79%
     BenchmarkChunkEncryptParallel     103            100            -2.91%
     BenchmarkArchiveDirectory         383704         392083         +2.18%
     BenchmarkPreload                  21765          21874          +0.50%
     BenchmarkLoadTree                 341            436            +27.86%
     BenchmarkEncryptWriter            20             17             -15.00%
     BenchmarkEncrypt                  14             13             -7.14%
     BenchmarkDecryptReader            18             15             -16.67%
     BenchmarkEncryptDecryptReader     46             39             -15.22%
     BenchmarkDecrypt                  16             12             -25.00%
     BenchmarkSaveJSON                 81             86             +6.17%
     BenchmarkSaveFrom                 117            121            +3.42%
     BenchmarkLoadJSONID               80525          80264          -0.32%

     benchmark                         old bytes     new bytes     delta
     BenchmarkChunkEncrypt             118956        64697         -45.61%
     BenchmarkChunkEncryptParallel     118972        64681         -45.63%
     BenchmarkArchiveDirectory         160236600     177498232     +10.77%
     BenchmarkPreload                  2772488       3302992       +19.13%
     BenchmarkLoadTree                 49102         46484         -5.33%
     BenchmarkEncryptWriter            28927         8388146       +28897.64%
     BenchmarkEncrypt                  2473          1950          -21.15%
     BenchmarkDecryptReader            527827        2774          -99.47%
     BenchmarkEncryptDecryptReader     4100875       1528036       -62.74%
     BenchmarkDecrypt                  2509          2154          -14.15%
     BenchmarkSaveJSON                 4971          5892          +18.53%
     BenchmarkSaveFrom                 40117         31742         -20.88%
     BenchmarkLoadJSONID               9444217       9442106       -0.02%

This closes #102.
2015-03-14 20:00:41 +01:00
Alexander Neumann
2f3aa344af Make decryptReader fulfill flate.Reader
benchmark               old ns/op     new ns/op     delta
    BenchmarkLoadJSONID     50232171      48596972      -3.26%

    benchmark               old allocs     new allocs     delta
    BenchmarkLoadJSONID     43643          42884          -1.74%

    benchmark               old bytes     new bytes     delta
    BenchmarkLoadJSONID     5773048       3785517       -34.43%
2015-02-18 23:30:59 +01:00
Alexander Neumann
68141c738b Correct length of plaintext before decryption 2015-02-18 20:44:21 +01:00
Alexander Neumann
b6f25aa690 Remove Each(), add basic stats 2015-02-17 23:11:56 +01:00
Alexander Neumann
5a16a66973 Add 'plaintext' parameter to key.Decrypt()
% benchcmp /tmp/{before,after}
    benchmark                         old ns/op     new ns/op     delta
    BenchmarkChunkEncrypt             261144414     260252046     -0.34%
    BenchmarkChunkEncryptParallel     261201438     261267029     +0.03%
    BenchmarkArchiveDirectory         0.00          0.00          +0.00%
    BenchmarkEncryptWriter            88297245      87526529      -0.87%
    BenchmarkEncrypt                  87406446      87917897      +0.59%
    BenchmarkDecryptReader            89948630      90042541      +0.10%
    BenchmarkEncryptDecryptReader     178374144     179477306     +0.62%
    BenchmarkDecrypt                  88289705      87937073      -0.40%
    BenchmarkSaveJSON                 213917        213571        -0.16%
    BenchmarkSaveFrom                 74881361      75111148      +0.31%

    benchmark                         old MB/s     new MB/s     speedup
    BenchmarkChunkEncrypt             40.15        40.29        1.00x
    BenchmarkChunkEncryptParallel     40.14        40.13        1.00x
    BenchmarkEncryptWriter            95.00        95.84        1.01x
    BenchmarkEncrypt                  95.97        95.41        0.99x
    BenchmarkDecryptReader            93.26        93.16        1.00x
    BenchmarkEncryptDecryptReader     47.03        46.74        0.99x
    BenchmarkDecrypt                  95.01        95.39        1.00x
    BenchmarkSaveFrom                 56.01        55.84        1.00x

    benchmark                         old allocs     new allocs     delta
    BenchmarkChunkEncrypt             113            112            -0.88%
    BenchmarkChunkEncryptParallel     104            103            -0.96%
    BenchmarkArchiveDirectory         0              0              +0.00%
    BenchmarkEncryptWriter            20             20             +0.00%
    BenchmarkEncrypt                  14             14             +0.00%
    BenchmarkDecryptReader            18             18             +0.00%
    BenchmarkEncryptDecryptReader     40             45             +12.50%
    BenchmarkDecrypt                  17             16             -5.88%
    BenchmarkSaveJSON                 125            125            +0.00%
    BenchmarkSaveFrom                 116            119            +2.59%

    benchmark                         old bytes     new bytes     delta
    BenchmarkChunkEncrypt             8515750       118956        -98.60%
    BenchmarkChunkEncryptParallel     8515766       118972        -98.60%
    BenchmarkArchiveDirectory         0             0             +0.00%
    BenchmarkEncryptWriter            28927         28927         +0.00%
    BenchmarkEncrypt                  422313        2473          -99.41%
    BenchmarkDecryptReader            527827        527827        +0.00%
    BenchmarkEncryptDecryptReader     4100824       4100870       +0.00%
    BenchmarkDecrypt                  8391127       2509          -99.97%
    BenchmarkSaveJSON                 9208          9208          +0.00%
    BenchmarkSaveFrom                 39694         40541         +2.13%
2015-02-17 21:10:26 +01:00
Alexander Neumann
af57fb86d7 Reduce memory usage of decryptReader
benchmark                         old ns/op     new ns/op     delta
    BenchmarkChunkEncrypt             260007360     261144414     +0.44%
    BenchmarkChunkEncryptParallel     262839697     261201438     -0.62%
    BenchmarkArchiveDirectory         0.00          0.00          +0.00%
    BenchmarkEncryptWriter            86994839      88297245      +1.50%
    BenchmarkEncrypt                  87414849      87406446      -0.01%
    BenchmarkDecryptReader            90354651      89948630      -0.45%
    BenchmarkEncryptDecryptReader     184533845     178374144     -3.34%
    BenchmarkDecrypt                  88153894      88289705      +0.15%
    BenchmarkSaveJSON                 213906        213917        +0.01%
    BenchmarkSaveFrom                 75263853      74881361      -0.51%

    benchmark                         old MB/s     new MB/s     speedup
    BenchmarkChunkEncrypt             40.33        40.15        1.00x
    BenchmarkChunkEncryptParallel     39.89        40.14        1.01x
    BenchmarkEncryptWriter            96.43        95.00        0.99x
    BenchmarkEncrypt                  95.96        95.97        1.00x
    BenchmarkDecryptReader            92.84        93.26        1.00x
    BenchmarkEncryptDecryptReader     45.46        47.03        1.03x
    BenchmarkDecrypt                  95.16        95.01        1.00x
    BenchmarkSaveFrom                 55.73        56.01        1.01x

    benchmark                         old allocs     new allocs     delta
    BenchmarkChunkEncrypt             113            113            +0.00%
    BenchmarkChunkEncryptParallel     104            104            +0.00%
    BenchmarkArchiveDirectory         0              0              +0.00%
    BenchmarkEncryptWriter            20             20             +0.00%
    BenchmarkEncrypt                  14             14             +0.00%
    BenchmarkDecryptReader            18             18             +0.00%
    BenchmarkEncryptDecryptReader     55             40             -27.27%
    BenchmarkDecrypt                  17             17             +0.00%
    BenchmarkSaveJSON                 125            125            +0.00%
    BenchmarkSaveFrom                 119            116            -2.52%

    benchmark                         old bytes     new bytes     delta
    BenchmarkChunkEncrypt             8515750       8515750       +0.00%
    BenchmarkChunkEncryptParallel     8515766       8515766       +0.00%
    BenchmarkArchiveDirectory         0             0             +0.00%
    BenchmarkEncryptWriter            28927         28927         +0.00%
    BenchmarkEncrypt                  422313        422313        +0.00%
    BenchmarkDecryptReader            527827        527827        +0.00%
    BenchmarkEncryptDecryptReader     35814894      4100824       -88.55%
    BenchmarkDecrypt                  8391127       8391127       +0.00%
    BenchmarkSaveJSON                 9208          9208          +0.00%
    BenchmarkSaveFrom                 40541         39694         -2.09%
2015-02-17 18:14:56 +01:00
Alexander Neumann
874b29b91f Improve memory usage (and speed) of crypto reader/writer
benchcmp:

    benchmark                         old ns/op     new ns/op     delta
    BenchmarkChunkEncrypt             260811933     261294510     +0.19%
    BenchmarkChunkEncryptParallel     262787948     259394601     -1.29%
    BenchmarkEncryptWriter            89769328      87108804      -2.96%
    BenchmarkEncrypt                  88586645      87489151      -1.24%
    BenchmarkDecryptReader            99669425      90019414      -9.68%
    BenchmarkEncryptDecryptReader     189263157     185185733     -2.15%
    BenchmarkDecrypt                  89631109      89172417      -0.51%

    benchmark                         old MB/s     new MB/s     speedup
    BenchmarkChunkEncrypt             40.20        40.13        1.00x
    BenchmarkChunkEncryptParallel     39.90        40.42        1.01x
    BenchmarkEncryptWriter            93.45        96.30        1.03x
    BenchmarkEncrypt                  94.69        95.88        1.01x
    BenchmarkDecryptReader            84.16        93.19        1.11x
    BenchmarkEncryptDecryptReader     44.32        45.30        1.02x
    BenchmarkDecrypt                  93.59        94.07        1.01x

    benchmark                         old allocs     new allocs     delta
    BenchmarkChunkEncrypt             113            113            +0.00%
    BenchmarkChunkEncryptParallel     104            104            +0.00%
    BenchmarkEncryptWriter            20             20             +0.00%
    BenchmarkEncrypt                  14             14             +0.00%
    BenchmarkDecryptReader            38             18             -52.63%
    BenchmarkEncryptDecryptReader     61             55             -9.84%
    BenchmarkDecrypt                  17             17             +0.00%

    benchmark                         old bytes     new bytes     delta
    BenchmarkChunkEncrypt             8515750       8515750       +0.00%
    BenchmarkChunkEncryptParallel     8515766       8515766       +0.00%
    BenchmarkEncryptWriter            8391305       28927         -99.66%
    BenchmarkEncrypt                  2475          2475          +0.00%
    BenchmarkDecryptReader            33563550      527827        -98.43%
    BenchmarkEncryptDecryptReader     50348456      35814894      -28.87%
    BenchmarkDecrypt                  8391127       8391127       +0.00%
2015-02-16 22:35:46 +01:00
Alexander Neumann
259389f7d1 EncryptWriter: do not close underlying writer 2015-02-16 00:22:46 +01:00
Alexander Neumann
3dbe02182b Remove EncryptFrom*() methods, add Tests for EncryptTo() 2015-02-15 23:38:45 +01:00
Alexander Neumann
5801d9f42f Add EncryptTo() methods 2015-02-15 18:13:42 +01:00
Alexander Neumann
72c951a6ec Simply backend interface
Rename CreateBlob() method to Create(), remove old Create* methods
2015-02-15 17:26:20 +01:00
Alexander Neumann
64f7b4e5e9 Rename HashReader -> HashAppendReader, add HashingReader 2015-02-11 19:37:48 +01:00
Alexander Neumann
5f0cce8546 Move HashReader to backend 2015-02-11 19:20:45 +01:00
Alexander Neumann
a564a454c4 Add stream functions for decrypt 2015-02-11 18:36:31 +01:00
Alexander Neumann
c6901af5aa Add streaming encrypt functions 2015-02-11 18:05:43 +01:00
Sebastian Schmidt
24cb360b5d Fix typo 2014-12-29 12:39:43 +01:00
Alexander Neumann
5431b025a3 Reduce code duplication in key handling 2014-12-21 18:16:22 +01:00
Alexander Neumann
cc147c002e Introduce type Server 2014-12-21 17:37:29 +01:00
Alexander Neumann
e2fea0d088 Rename khepri -> restic 2014-12-05 21:45:49 +01:00
Alexander Neumann
c0b3021494 Correctly deal with empty files 2014-11-30 16:24:27 +01:00
Alexander Neumann
43ccee3b08 Add command "key rm" 2014-11-25 23:18:02 +01:00
Alexander Neumann
f7fcd7c04c Add command "key add" 2014-11-25 23:07:00 +01:00
Alexander Neumann
4ab3d51996 Add more checks befor decrypting data 2014-11-24 22:11:09 +01:00
Alexander Neumann
79a1ad50ee Remove check for minimum buffer length 2014-11-23 23:02:15 +01:00
Alexander Neumann
719e121c74 Use large, dynamic buffer for encrypting maps 2014-11-23 22:58:41 +01:00
Alexander Neumann
f95788ed90 Limit memory usage, add several sync.Pool 2014-11-23 21:26:20 +01:00
Alexander Neumann
ebd4f97350 Update import path 2014-11-15 19:04:32 +01:00
Alexander Neumann
6003430eb9 Rework key.go, add Comments 2014-11-15 17:18:40 +01:00
Alexander Neumann
58f7b1be1e Use CTR instead of CBC for encryption 2014-11-15 17:12:52 +01:00
Alexander Neumann
30ab03b7b7 Add decrypt, refactor 2014-10-03 21:44:55 +02:00