Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
4ca8086a
Commit
4ca8086a
authored
Jan 04, 2017
by
ylecollen
Browse files
OlmSession triggers exception when there is a failure.
parent
846ea49a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java
View file @
4ca8086a
...
@@ -131,9 +131,18 @@ public class OlmSessionTest {
...
@@ -131,9 +131,18 @@ public class OlmSessionTest {
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
assertNotNull
(
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
));
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
String
clearMsg
=
"Heloo bob , this is alice!"
;
String
clearMsg
=
"Heloo bob , this is alice!"
;
OlmMessage
encryptedMsgToBob
=
aliceSession
.
encryptMessage
(
clearMsg
);
OlmMessage
encryptedMsgToBob
=
null
;
try
{
encryptedMsgToBob
=
aliceSession
.
encryptMessage
(
clearMsg
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsgToBob
);
assertNotNull
(
encryptedMsgToBob
);
assertNotNull
(
encryptedMsgToBob
.
mCipherText
);
assertNotNull
(
encryptedMsgToBob
.
mCipherText
);
Log
.
d
(
LOG_TAG
,
"## test01AliceToBob(): encryptedMsg="
+
encryptedMsgToBob
.
mCipherText
);
Log
.
d
(
LOG_TAG
,
"## test01AliceToBob(): encryptedMsg="
+
encryptedMsgToBob
.
mCipherText
);
...
@@ -153,7 +162,12 @@ public class OlmSessionTest {
...
@@ -153,7 +162,12 @@ public class OlmSessionTest {
assertTrue
(
"initInboundSessionWithAccount failed "
+
e
.
getMessage
(),
false
);
assertTrue
(
"initInboundSessionWithAccount failed "
+
e
.
getMessage
(),
false
);
}
}
String
decryptedMsg
=
bobSession
.
decryptMessage
(
encryptedMsgToBob
);
String
decryptedMsg
=
null
;
try
{
decryptedMsg
=
bobSession
.
decryptMessage
(
encryptedMsgToBob
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg
);
assertNotNull
(
decryptedMsg
);
// MESSAGE COMPARISON: decrypted vs encrypted
// MESSAGE COMPARISON: decrypted vs encrypted
...
@@ -255,10 +269,22 @@ public class OlmSessionTest {
...
@@ -255,10 +269,22 @@ public class OlmSessionTest {
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
assertNotNull
(
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
));
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
String
helloClearMsg
=
"Hello I'm Alice!"
;
String
helloClearMsg
=
"Hello I'm Alice!"
;
OlmMessage
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
helloClearMsg
);
OlmMessage
encryptedAliceToBobMsg1
=
null
;
try
{
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
helloClearMsg
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedAliceToBobMsg1
);
assertNotNull
(
encryptedAliceToBobMsg1
);
assertNotNull
(
encryptedAliceToBobMsg1
.
mCipherText
);
assertNotNull
(
encryptedAliceToBobMsg1
.
mCipherText
);
...
@@ -279,7 +305,12 @@ public class OlmSessionTest {
...
@@ -279,7 +305,12 @@ public class OlmSessionTest {
}
}
// DECRYPT MESSAGE FROM ALICE
// DECRYPT MESSAGE FROM ALICE
String
decryptedMsg01
=
bobSession
.
decryptMessage
(
encryptedAliceToBobMsg1
);
String
decryptedMsg01
=
null
;
try
{
decryptedMsg01
=
bobSession
.
decryptMessage
(
encryptedAliceToBobMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg01
);
assertNotNull
(
decryptedMsg01
);
// MESSAGE COMPARISON: decrypted vs encrypted
// MESSAGE COMPARISON: decrypted vs encrypted
...
@@ -291,19 +322,54 @@ public class OlmSessionTest {
...
@@ -291,19 +322,54 @@ public class OlmSessionTest {
String
clearMsg3
=
"Let's go to the opera."
;
String
clearMsg3
=
"Let's go to the opera."
;
// bob encrypts messages
// bob encrypts messages
OlmMessage
encryptedMsg1
=
bobSession
.
encryptMessage
(
clearMsg1
);
OlmMessage
encryptedMsg1
=
null
;
try
{
encryptedMsg1
=
bobSession
.
encryptMessage
(
clearMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg1
);
assertNotNull
(
encryptedMsg1
);
OlmMessage
encryptedMsg2
=
bobSession
.
encryptMessage
(
clearMsg2
);
OlmMessage
encryptedMsg2
=
null
;
try
{
encryptedMsg2
=
bobSession
.
encryptMessage
(
clearMsg2
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg2
);
assertNotNull
(
encryptedMsg2
);
OlmMessage
encryptedMsg3
=
bobSession
.
encryptMessage
(
clearMsg3
);
OlmMessage
encryptedMsg3
=
null
;
try
{
encryptedMsg3
=
bobSession
.
encryptMessage
(
clearMsg3
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg3
);
assertNotNull
(
encryptedMsg3
);
// alice decrypts bob's messages
// alice decrypts bob's messages
String
decryptedMsg1
=
aliceSession
.
decryptMessage
(
encryptedMsg1
);
String
decryptedMsg1
=
null
;
try
{
decryptedMsg1
=
aliceSession
.
decryptMessage
(
encryptedMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg1
);
assertNotNull
(
decryptedMsg1
);
String
decryptedMsg2
=
aliceSession
.
decryptMessage
(
encryptedMsg2
);
String
decryptedMsg2
=
null
;
try
{
decryptedMsg2
=
aliceSession
.
decryptMessage
(
encryptedMsg2
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg2
);
assertNotNull
(
decryptedMsg2
);
String
decryptedMsg3
=
aliceSession
.
decryptMessage
(
encryptedMsg3
);
String
decryptedMsg3
=
null
;
try
{
decryptedMsg3
=
aliceSession
.
decryptMessage
(
encryptedMsg3
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg3
);
assertNotNull
(
decryptedMsg3
);
// comparison tests
// comparison tests
...
@@ -313,9 +379,22 @@ public class OlmSessionTest {
...
@@ -313,9 +379,22 @@ public class OlmSessionTest {
// and one more from alice to bob
// and one more from alice to bob
clearMsg1
=
"another message from Alice to Bob!!"
;
clearMsg1
=
"another message from Alice to Bob!!"
;
encryptedMsg1
=
aliceSession
.
encryptMessage
(
clearMsg1
);
encryptedMsg1
=
null
;
try
{
encryptedMsg1
=
aliceSession
.
encryptMessage
(
clearMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg1
);
assertNotNull
(
encryptedMsg1
);
decryptedMsg1
=
bobSession
.
decryptMessage
(
encryptedMsg1
);
decryptedMsg1
=
null
;
try
{
decryptedMsg1
=
bobSession
.
decryptMessage
(
encryptedMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg1
);
assertNotNull
(
decryptedMsg1
);
assertTrue
(
clearMsg1
.
equals
(
decryptedMsg1
));
assertTrue
(
clearMsg1
.
equals
(
decryptedMsg1
));
...
@@ -378,10 +457,21 @@ public class OlmSessionTest {
...
@@ -378,10 +457,21 @@ public class OlmSessionTest {
}
}
assertTrue
(
0
!=
bobSession
.
getOlmSessionId
());
assertTrue
(
0
!=
bobSession
.
getOlmSessionId
());
String
aliceSessionId
=
aliceSession
.
sessionIdentifier
();
String
aliceSessionId
=
null
;
try
{
aliceSessionId
=
aliceSession
.
sessionIdentifier
();
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
aliceSessionId
);
assertNotNull
(
aliceSessionId
);
String
bobSessionId
=
bobSession
.
sessionIdentifier
();
String
bobSessionId
=
null
;
try
{
bobSessionId
=
bobSession
.
sessionIdentifier
();
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
bobSessionId
);
assertNotNull
(
bobSessionId
);
// must be the same for both ends of the conversation
// must be the same for both ends of the conversation
...
@@ -463,10 +553,21 @@ public class OlmSessionTest {
...
@@ -463,10 +553,21 @@ public class OlmSessionTest {
String
bobOneTimeKey1
=
TestHelper
.
getOneTimeKey
(
bobOneTimeKeys
,
1
);
String
bobOneTimeKey1
=
TestHelper
.
getOneTimeKey
(
bobOneTimeKeys
,
1
);
// create alice inbound session for bob
// create alice inbound session for bob
assertTrue
(
0
==
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey1
));
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
String
aliceClearMsg
=
"hello helooo to bob!"
;
String
aliceClearMsg
=
"hello helooo to bob!"
;
OlmMessage
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
aliceClearMsg
);
OlmMessage
encryptedAliceToBobMsg1
=
null
;
try
{
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
aliceClearMsg
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertFalse
(
bobSession
.
matchesInboundSession
(
encryptedAliceToBobMsg1
.
mCipherText
));
assertFalse
(
bobSession
.
matchesInboundSession
(
encryptedAliceToBobMsg1
.
mCipherText
));
// init bob session with alice PRE KEY
// init bob session with alice PRE KEY
...
@@ -571,10 +672,20 @@ public class OlmSessionTest {
...
@@ -571,10 +672,20 @@ public class OlmSessionTest {
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
assertTrue
(
0
!=
aliceSession
.
getOlmSessionId
());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
assertNotNull
(
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
));
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
String
helloClearMsg
=
"Hello I'm Alice!"
;
String
helloClearMsg
=
"Hello I'm Alice!"
;
OlmMessage
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
helloClearMsg
);
OlmMessage
encryptedAliceToBobMsg1
=
null
;
try
{
encryptedAliceToBobMsg1
=
aliceSession
.
encryptMessage
(
helloClearMsg
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedAliceToBobMsg1
);
assertNotNull
(
encryptedAliceToBobMsg1
);
assertNotNull
(
encryptedAliceToBobMsg1
.
mCipherText
);
assertNotNull
(
encryptedAliceToBobMsg1
.
mCipherText
);
...
@@ -595,7 +706,14 @@ public class OlmSessionTest {
...
@@ -595,7 +706,14 @@ public class OlmSessionTest {
}
}
// DECRYPT MESSAGE FROM ALICE
// DECRYPT MESSAGE FROM ALICE
String
decryptedMsg01
=
bobSession
.
decryptMessage
(
encryptedAliceToBobMsg1
);
String
decryptedMsg01
=
null
;
try
{
decryptedMsg01
=
bobSession
.
decryptMessage
(
encryptedAliceToBobMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
decryptedMsg01
);
assertNotNull
(
decryptedMsg01
);
// MESSAGE COMPARISON: decrypted vs encrypted
// MESSAGE COMPARISON: decrypted vs encrypted
...
@@ -607,11 +725,28 @@ public class OlmSessionTest {
...
@@ -607,11 +725,28 @@ public class OlmSessionTest {
String
clearMsg3
=
"Let's go to the opera."
;
String
clearMsg3
=
"Let's go to the opera."
;
// bob encrypts messages
// bob encrypts messages
OlmMessage
encryptedMsg1
=
bobSession
.
encryptMessage
(
clearMsg1
);
OlmMessage
encryptedMsg1
=
null
;
try
{
encryptedMsg1
=
bobSession
.
encryptMessage
(
clearMsg1
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg1
);
assertNotNull
(
encryptedMsg1
);
OlmMessage
encryptedMsg2
=
bobSession
.
encryptMessage
(
clearMsg2
);
OlmMessage
encryptedMsg2
=
null
;
try
{
encryptedMsg2
=
bobSession
.
encryptMessage
(
clearMsg2
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg2
);
assertNotNull
(
encryptedMsg2
);
OlmMessage
encryptedMsg3
=
bobSession
.
encryptMessage
(
clearMsg3
);
OlmMessage
encryptedMsg3
=
null
;
try
{
encryptedMsg3
=
bobSession
.
encryptMessage
(
clearMsg3
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsg3
);
assertNotNull
(
encryptedMsg3
);
// serialize alice session
// serialize alice session
...
@@ -742,26 +877,70 @@ public class OlmSessionTest {
...
@@ -742,26 +877,70 @@ public class OlmSessionTest {
}
}
// SANITY CHECK TESTS FOR: initOutboundSessionWithAccount()
// SANITY CHECK TESTS FOR: initOutboundSessionWithAccount()
assertTrue
(-
1
==
aliceSession
.
initOutboundSession
(
null
,
bobIdentityKey
,
bobOneTimeKey
));
String
errorMessage
=
null
;
assertTrue
(-
1
==
aliceSession
.
initOutboundSession
(
aliceAccount
,
null
,
bobOneTimeKey
));
try
{
assertTrue
(-
1
==
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
null
));
aliceSession
.
initOutboundSession
(
null
,
bobIdentityKey
,
bobOneTimeKey
);
assertTrue
(-
1
==
aliceSession
.
initOutboundSession
(
null
,
null
,
null
));
}
catch
(
Exception
e
)
{
errorMessage
=
e
.
getMessage
();
}
assertTrue
(
null
!=
errorMessage
);
errorMessage
=
null
;
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
null
,
bobOneTimeKey
);
}
catch
(
Exception
e
)
{
errorMessage
=
e
.
getMessage
();
}
assertTrue
(
null
!=
errorMessage
);
errorMessage
=
null
;
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
null
);
}
catch
(
Exception
e
)
{
errorMessage
=
e
.
getMessage
();
}
assertTrue
(
null
!=
errorMessage
);
errorMessage
=
null
;
try
{
aliceSession
.
initOutboundSession
(
null
,
null
,
null
);
}
catch
(
Exception
e
)
{
errorMessage
=
e
.
getMessage
();
}
assertTrue
(
null
!=
errorMessage
);
// init properly
// init properly
assertTrue
(
0
==
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
));
errorMessage
=
null
;
try
{
aliceSession
.
initOutboundSession
(
aliceAccount
,
bobIdentityKey
,
bobOneTimeKey
);
}
catch
(
Exception
e
)
{
errorMessage
=
e
.
getMessage
();
}
assertTrue
(
null
==
errorMessage
);
// SANITY CHECK TESTS FOR: encryptMessage()
// SANITY CHECK TESTS FOR: encryptMessage()
assertTrue
(
null
==
aliceSession
.
encryptMessage
(
null
));
OlmMessage
message
=
null
;
try
{
message
=
aliceSession
.
encryptMessage
(
null
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertTrue
(
null
==
message
);
// encrypt properly
// encrypt properly
OlmMessage
encryptedMsgToBob
=
aliceSession
.
encryptMessage
(
"A message for bob"
);
OlmMessage
encryptedMsgToBob
=
null
;
try
{
encryptedMsgToBob
=
aliceSession
.
encryptMessage
(
"A message for bob"
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertNotNull
(
encryptedMsgToBob
);
assertNotNull
(
encryptedMsgToBob
);
// SANITY CHECK TESTS FOR: initInboundSessionWithAccount()
// SANITY CHECK TESTS FOR: initInboundSessionWithAccount()
OlmSession
bobSession
=
null
;
OlmSession
bobSession
=
null
;
try
{
try
{
bobSession
=
new
OlmSession
();
bobSession
=
new
OlmSession
();
String
errorMessage
=
null
;
errorMessage
=
null
;
try
{
try
{
bobSession
.
initInboundSession
(
null
,
encryptedMsgToBob
.
mCipherText
);
bobSession
.
initInboundSession
(
null
,
encryptedMsgToBob
.
mCipherText
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -802,7 +981,13 @@ public class OlmSessionTest {
...
@@ -802,7 +981,13 @@ public class OlmSessionTest {
}
}
// SANITY CHECK TESTS FOR: decryptMessage()
// SANITY CHECK TESTS FOR: decryptMessage()
String
decryptedMsg
=
aliceSession
.
decryptMessage
(
null
);
String
decryptedMsg
=
null
;
try
{
decryptedMsg
=
aliceSession
.
decryptMessage
(
null
);
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
(),
false
);
}
assertTrue
(
null
==
decryptedMsg
);
assertTrue
(
null
==
decryptedMsg
);
// SANITY CHECK TESTS FOR: matchesInboundSession()
// SANITY CHECK TESTS FOR: matchesInboundSession()
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java
View file @
4ca8086a
...
@@ -24,41 +24,40 @@ import java.io.IOException;
...
@@ -24,41 +24,40 @@ import java.io.IOException;
*/
*/
public
class
OlmException
extends
IOException
{
public
class
OlmException
extends
IOException
{
// exception codes
// exception codes
public
static
final
int
EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION
=
0
;
public
static
final
int
EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION
=
1
;
public
static
final
int
EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION
=
2
;
public
static
final
int
EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION
=
3
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_SERIALIZATION
=
4
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_DESERIALIZATION
=
5
;
public
static
final
int
EXCEPTION_CODE_SESSION_SERIALIZATION
=
6
;
public
static
final
int
EXCEPTION_CODE_SESSION_DESERIALIZATION
=
7
;
public
static
final
int
EXCEPTION_CODE_INIT_ACCOUNT_CREATION
=
8
;
public
static
final
int
EXCEPTION_CODE_INIT_SESSION_CREATION
=
9
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_SERIALIZATION
=
10
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_DESERIALIZATION
=
11
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_SERIALIZATION
=
12
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
=
13
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_IDENTITY_KEYS
=
20
;
public
static
final
int
EXCEPTION_CODE_INIT_ACCOUNT_CREATION
=
10
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_GENERATE_ONE_TIME_KEYS
=
21
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_ONE_TIME_KEYS
=
22
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_REMOVE_ONE_TIME_KEYS
=
23
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_MARK_ONE_KEYS_AS_PUBLISHED
=
24
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_SIGN_MESSAGE
=
25
;
public
static
final
int
EXCEPTION_CODE_SESSION_IDENTIFIER
=
30
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_SERIALIZATION
=
20
;
public
static
final
int
EXCEPTION_CODE_SESSION_DECRYPT_SESSION
=
31
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_DESERIALIZATION
=
21
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_IDENTITY_KEYS
=
22
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_GENERATE_ONE_TIME_KEYS
=
23
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_ONE_TIME_KEYS
=
24
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_REMOVE_ONE_TIME_KEYS
=
25
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_MARK_ONE_KEYS_AS_PUBLISHED
=
26
;
public
static
final
int
EXCEPTION_CODE_ACCOUNT_SIGN_MESSAGE
=
27
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_IDENTIFIER
=
40
;
public
static
final
int
EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION
=
30
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_KEY
=
41
;
public
static
final
int
EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION
=
31
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_ENCRYPT_MESSAGE
=
42
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_IDENTIFIER
=
32
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DECRYPT_SESSION
=
33
;
public
static
final
int
EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION
=
40
;
public
static
final
int
EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION
=
41
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_IDENTIFIER
=
42
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_KEY
=
43
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_ENCRYPT_MESSAGE
=
44
;
public
static
final
int
EXCEPTION_CODE_INIT_SESSION_CREATION
=
50
;
public
static
final
int
EXCEPTION_CODE_SESSION_INIT_OUTBOUND_SESSION
=
51
;
public
static
final
int
EXCEPTION_CODE_SESSION_INIT_INBOUND_SESSION
=
52
;
public
static
final
int
EXCEPTION_CODE_SESSION_INIT_INBOUND_SESSION_FROM
=
53
;
public
static
final
int
EXCEPTION_CODE_SESSION_ENCRYPT_MESSAGE
=
54
;
public
static
final
int
EXCEPTION_CODE_SESSION_DECRYPT_MESSAGE
=
55
;
public
static
final
int
EXCEPTION_CODE_SESSION_SESSION_IDENTIFIER
=
56
;
// exception human readable messages
// exception human readable messages
public
static
final
String
EXCEPTION_MSG_NEW_OUTBOUND_GROUP_SESSION
=
"createNewSession() failed"
;
public
static
final
String
EXCEPTION_MSG_NEW_OUTBOUND_GROUP_SESSION
=
"createNewSession() failed"
;
public
static
final
String
EXCEPTION_MSG_NEW_INBOUND_GROUP_SESSION
=
"createNewSession() failed"
;
public
static
final
String
EXCEPTION_MSG_NEW_INBOUND_GROUP_SESSION
=
"createNewSession() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_OUTBOUND_GROUP_SESSION
=
"initOutboundGroupSession() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_INBOUND_GROUP_SESSION
=
" initInboundGroupSessionWithSessionKey() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_NEW_ACCOUNT_DESERIALIZATION
=
"initNewAccount() failure"
;
public
static
final
String
EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION
=
"invalid de-serialized parameters"
;
public
static
final
String
EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION
=
"invalid de-serialized parameters"
;
public
static
final
String
EXCEPTION_MSG_INIT_ACCOUNT_CREATION
=
"initNewAccount() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_ACCOUNT_CREATION
=
"initNewAccount() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_SESSION_CREATION
=
"initNewSession() failed"
;
public
static
final
String
EXCEPTION_MSG_INIT_SESSION_CREATION
=
"initNewSession() failed"
;
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
View file @
4ca8086a
...
@@ -141,7 +141,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
...
@@ -141,7 +141,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
return
new
String
(
sessionIdentifierJni
(),
"UTF-8"
);
return
new
String
(
sessionIdentifierJni
(),
"UTF-8"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"## sessionIdentifier() failed "
+
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
"## sessionIdentifier() failed "
+
e
.
getMessage
());
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_SESSION_IDENTIFIER
,
e
.
getMessage
());
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_
INBOUND_GROUP_
SESSION_IDENTIFIER
,
e
.
getMessage
());
}
}
}
}
...
@@ -165,7 +165,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
...
@@ -165,7 +165,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"## decryptMessage() failed "
+
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
"## decryptMessage() failed "
+
e
.
getMessage
());
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_SESSION_DECRYPT_SESSION
,
e
.
getMessage
());
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_
INBOUND_GROUP_
SESSION_DECRYPT_SESSION
,
e
.
getMessage
());
}
}
return
result
;
return
result
;
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
View file @
4ca8086a
...
@@ -124,25 +124,23 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
...
@@ -124,25 +124,23 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
* @param aAccount the account to associate with this session
* @param aAccount the account to associate with this session
* @param aTheirIdentityKey the identity key of the recipient
* @param aTheirIdentityKey the identity key of the recipient
* @param aTheirOneTimeKey the one time key of the recipient
* @param aTheirOneTimeKey the one time key of the recipient
* @
return 0 if operation succeed, -1 otherwise
* @
exception OlmException the failure reason
*/
*/
public
int
initOutboundSession
(
OlmAccount
aAccount
,
String
aTheirIdentityKey
,
String
aTheirOneTimeKey
)
{