Code quality

This commit is contained in:
Benoit Marty 2020-02-26 12:43:41 +01:00
parent f35b0660ca
commit 6622e0daca
1 changed files with 5 additions and 3 deletions

View File

@ -220,14 +220,16 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
} }
/** /**
* Encrytion algorithm m.secret_storage.v1.aes-hmac-sha2 * Encryption algorithm m.secret_storage.v1.aes-hmac-sha2
* Secrets are encrypted using AES-CTR-256 and MACed using HMAC-SHA-256. The data is encrypted and MACed as follows: * Secrets are encrypted using AES-CTR-256 and MACed using HMAC-SHA-256. The data is encrypted and MACed as follows:
* *
* Given the secret storage key, generate 64 bytes by performing an HKDF with SHA-256 as the hash, a salt of 32 bytes of 0, and with the secret name as the info. * Given the secret storage key, generate 64 bytes by performing an HKDF with SHA-256 as the hash, a salt of 32 bytes
* of 0, and with the secret name as the info.
* *
* The first 32 bytes are used as the AES key, and the next 32 bytes are used as the MAC key * The first 32 bytes are used as the AES key, and the next 32 bytes are used as the MAC key
* *
* Generate 16 random bytes, set bit 63 to 0 (in order to work around differences in AES-CTR implementations), and use this as the AES initialization vector. * Generate 16 random bytes, set bit 63 to 0 (in order to work around differences in AES-CTR implementations), and use
* this as the AES initialization vector.
* This becomes the iv property, encoded using base64. * This becomes the iv property, encoded using base64.
* *
* Encrypt the data using AES-CTR-256 using the AES key generated above. * Encrypt the data using AES-CTR-256 using the AES key generated above.