Closed pedrouid closed 5 years ago
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
This issue now has a funding of 100.0 DAI (100.0 USD @ $1.0/DAI) attached to it as part of the WalletConnect fund.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work has been started.
These users each claimed they can complete the work by 1 month, 3 weeks ago. Please review their action plans below:
1) iamonuwa has started work.
Skipped this task because I was thinking it was Objective C, On a closer look discovered its react native. Am available to work on this task. Will be ready before end of weekend.
Learn more on the Gitcoin Issue Details page.
2) bb2000 has started work.
Pull request already submitted to fix issue. I will also make any changes needed to make the solution acceptable.
Learn more on the Gitcoin Issue Details page.
Here is the WebCrypto API method for encrypting
async function aesCbcEncrypt (data, key, iv) {
const AES_ALGORITHM = 'AES-CBC'
const AES_LENGTH = 128
const cryptoKey = await window.crypto.subtle.importKey(
'raw',
key,
{ length: AES_LENGTH, name: AES_ALGORITHM },
true,
['encrypt', 'decrypt']
)
const result = await window.crypto.subtle.encrypt(
{
iv,
name: AES_ALGORITHM
},
cryptoKey,
data
)
return result
}
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work for 100.0 DAI (100.0 USD @ $1.0/DAI) has been submitted by:
@pedrouid please take a look at the submitted work:
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
The funding of 100.0 DAI (100.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @bb2000.
Currently the AES module in
react-native-simple-crypto
has two methods toencrypt
anddecrypt
using the AES-128-CBC algorithm. It correctly encrypts and decrypts cipherTexts encrypted by itself. However when passed a cipherText encrypted using the WebCrypto API with the same algorithm, the cipher fails to decrypt it.Example
Expected Result
Actual Result
The only occurence for this error message is Line 26 on file RCTAes.m https://github.com/WalletConnect/react-native-simple-crypto/blob/master/ios/RCTCrypto/RCTAes.m#L26 Which is returned by checking the result is
nil
from the cipher on file Aes.m https://github.com/WalletConnect/react-native-simple-crypto/blob/master/ios/RCTCrypto/lib/Aes.mAdditionally if we encrypt the same expected result with the same key and iv using the library, we get a different cipherText
I've checked the WebCrypto API and according to the spec it should follow the same algorithm AES-128-CBC with PKCS7 padding https://www.w3.org/TR/WebCryptoAPI/#aes-cbc-description