Android: CipherStream-API for AEAD Ciphers inacceptable slow

后端 未结 1 457
说谎
说谎 2021-01-07 00:33

We are having an android app which a decrypting and encrypting large (up to 100MB) files over HTTP-Streams.

Therefore, we are using CipherInputStreams a

1条回答
  •  生来不讨喜
    2021-01-07 01:30

    Splitting the file into the parts and chaining is a solution for you.

    Assume that you divide the file into n parts. Encrypt each of them with AES-GCM with the following additions. Prefix each part before encryption as follows;

    tag_0 = ''
    for i from 1 to n
        ciphertextBlock_i, tag_i = AES-GCM( i:n || tag_i-1 || plaintextBlock_i)
    
    • prefix each part with the part number as i:n
    • prefix each part except the first one with the authentication tag of the previous part.

    With these, you have now a chain that can be controlled after decryption. You can detect, additions, deletions. The order is under your control, you can send even without the order. However, you need to check the prefix.

    You can also

    • add the part size, and
    • add the time of encryption, too if you fear from the replay attack.

    0 讨论(0)
提交回复
热议问题