Skip to content

Commit

Permalink
Remove padding from base64 encoded iv value
Browse files Browse the repository at this point in the history
This uses the existing `MXBase64Tools` to trim the `=` padding from the base64
encoded string. The reinsertion of the padding prior to decoding was already
implemented (line 224 in the same file).

Closes: element-hq/element-ios#4172

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
  • Loading branch information
Johennes committed Apr 1, 2021
1 parent 6814ebb commit 3c7cb0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Changes to be released in next version
*

🐛 Bugfix
*
* Remove padding from base64 encoded `iv` value (vector-im/element-ios/issues/4172).

⚠️ API Changes
*
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Crypto/Data/MXEncryptedAttachments.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ + (void)encryptAttachment:(MXMediaLoader *)uploader
encryptedContentFile.url = url;
encryptedContentFile.mimetype = mimeType;
encryptedContentFile.key = encryptedContentKey;
encryptedContentFile.iv = [iv base64EncodedStringWithOptions:0];
encryptedContentFile.iv = [MXBase64Tools base64ToUnpaddedBase64:[iv base64EncodedStringWithOptions:0]];
encryptedContentFile.hashes = @{
@"sha256": [MXBase64Tools base64ToUnpaddedBase64:[computedSha256 base64EncodedStringWithOptions:0]],
};
Expand Down

0 comments on commit 3c7cb0b

Please sign in to comment.