@@ -3,6 +3,7 @@ package de.tutao.tutanota
3
3
import android.content.Context
4
4
import android.support.test.InstrumentationRegistry
5
5
import android.support.test.runner.AndroidJUnit4
6
+ import de.tutao.tutanota.AndroidNativeCryptoFacade.Companion.bytesToKey
6
7
import de.tutao.tutanota.ipc.RsaPrivateKey
7
8
import de.tutao.tutanota.ipc.RsaPublicKey
8
9
import de.tutao.tutanota.ipc.wrap
@@ -19,6 +20,7 @@ import java.io.IOException
19
20
import java.math.BigInteger
20
21
import java.security.SecureRandom
21
22
23
+
22
24
@RunWith(AndroidJUnit4 ::class )
23
25
class CompatibilityTest {
24
26
@Test
@@ -36,6 +38,30 @@ class CompatibilityTest {
36
38
}
37
39
}
38
40
41
+ @Test
42
+ @Throws(CryptoError ::class , IOException ::class )
43
+ fun aes128Key128Encryption () {
44
+ val crypto = AndroidNativeCryptoFacade (Mockito .mock(Context ::class .java))
45
+ for (td in testData!! .getAes128Tests()) {
46
+ val key = bytesToKey(hexToBytes(td.hexKey))
47
+ val keyToEncrypt128 = hexToBytes(td.keyToEncrypt128)
48
+ val encryptedKey = crypto.encryptKey(key, keyToEncrypt128)
49
+ Assert .assertEquals(td.encryptedKey128, encryptedKey.toBase64())
50
+ }
51
+ }
52
+
53
+ @Test
54
+ @Throws(CryptoError ::class , IOException ::class )
55
+ fun aes128Key256Encryption () {
56
+ val crypto = AndroidNativeCryptoFacade (Mockito .mock(Context ::class .java))
57
+ for (td in testData!! .getAes128Tests()) {
58
+ val key = bytesToKey(hexToBytes(td.hexKey))
59
+ val keyToEncrypt256 = hexToBytes(td.keyToEncrypt256)
60
+ val encryptedKey = crypto.encryptKey(key, keyToEncrypt256)
61
+ Assert .assertEquals(td.encryptedKey256, encryptedKey.toBase64())
62
+ }
63
+ }
64
+
39
65
@Test
40
66
@Throws(CryptoError ::class , IOException ::class )
41
67
fun aes128Mac () {
0 commit comments