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
3540926b
Commit
3540926b
authored
Dec 19, 2016
by
manuroe
Browse files
OLMKit: Reset intermediate buffers to zeroes
parent
aa12cbca
Changes
3
Hide whitespace changes
Inline
Side-by-side
xcode/OLMKit/OLMAccount.m
View file @
3540926b
...
@@ -66,6 +66,7 @@
...
@@ -66,6 +66,7 @@
size_t
randomLength
=
olm_create_account_random_length
(
_account
);
size_t
randomLength
=
olm_create_account_random_length
(
_account
);
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
randomLength
];
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
randomLength
];
size_t
accountResult
=
olm_create_account
(
_account
,
random
.
mutableBytes
,
random
.
length
);
size_t
accountResult
=
olm_create_account
(
_account
,
random
.
mutableBytes
,
random
.
length
);
[
random
resetBytesInRange
:
NSMakeRange
(
0
,
random
.
length
)];
if
(
accountResult
==
olm_error
())
{
if
(
accountResult
==
olm_error
())
{
const
char
*
error
=
olm_account_last_error
(
_account
);
const
char
*
error
=
olm_account_last_error
(
_account
);
NSLog
(
@"error creating account: %s"
,
error
);
NSLog
(
@"error creating account: %s"
,
error
);
...
@@ -147,6 +148,7 @@
...
@@ -147,6 +148,7 @@
size_t
randomLength
=
olm_account_generate_one_time_keys_random_length
(
_account
,
numberOfKeys
);
size_t
randomLength
=
olm_account_generate_one_time_keys_random_length
(
_account
,
numberOfKeys
);
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
randomLength
];
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
randomLength
];
size_t
result
=
olm_account_generate_one_time_keys
(
_account
,
numberOfKeys
,
random
.
mutableBytes
,
random
.
length
);
size_t
result
=
olm_account_generate_one_time_keys
(
_account
,
numberOfKeys
,
random
.
mutableBytes
,
random
.
length
);
[
random
resetBytesInRange
:
NSMakeRange
(
0
,
random
.
length
)];
if
(
result
==
olm_error
())
{
if
(
result
==
olm_error
())
{
const
char
*
error
=
olm_account_last_error
(
_account
);
const
char
*
error
=
olm_account_last_error
(
_account
);
NSLog
(
@"error generating keys: %s"
,
error
);
NSLog
(
@"error generating keys: %s"
,
error
);
...
...
xcode/OLMKit/OLMOutboundGroupSession.m
View file @
3540926b
...
@@ -55,6 +55,7 @@
...
@@ -55,6 +55,7 @@
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
olm_init_outbound_group_session_random_length
(
session
)];
NSMutableData
*
random
=
[
OLMUtility
randomBytesOfLength
:
olm_init_outbound_group_session_random_length
(
session
)];
size_t
result
=
olm_init_outbound_group_session
(
session
,
random
.
mutableBytes
,
random
.
length
);
size_t
result
=
olm_init_outbound_group_session
(
session
,
random
.
mutableBytes
,
random
.
length
);
[
random
resetBytesInRange
:
NSMakeRange
(
0
,
random
.
length
)];
if
(
result
==
olm_error
())
{
if
(
result
==
olm_error
())
{
const
char
*
error
=
olm_outbound_group_session_last_error
(
session
);
const
char
*
error
=
olm_outbound_group_session_last_error
(
session
);
NSLog
(
@"olm_init_outbound_group_session error: %s"
,
error
);
NSLog
(
@"olm_init_outbound_group_session error: %s"
,
error
);
...
@@ -97,6 +98,7 @@
...
@@ -97,6 +98,7 @@
return
nil
;
return
nil
;
}
}
NSString
*
sessionKey
=
[[
NSString
alloc
]
initWithData
:
sessionKeyData
encoding
:
NSUTF8StringEncoding
];
NSString
*
sessionKey
=
[[
NSString
alloc
]
initWithData
:
sessionKeyData
encoding
:
NSUTF8StringEncoding
];
[
sessionKeyData
resetBytesInRange
:
NSMakeRange
(
0
,
sessionKeyData
.
length
)];
return
sessionKey
;
return
sessionKey
;
}
}
...
...
xcode/OLMKit/OLMSession.m
View file @
3540926b
...
@@ -78,6 +78,7 @@
...
@@ -78,6 +78,7 @@
NSData
*
idKey
=
[
theirIdentityKey
dataUsingEncoding
:
NSUTF8StringEncoding
];
NSData
*
idKey
=
[
theirIdentityKey
dataUsingEncoding
:
NSUTF8StringEncoding
];
NSData
*
otKey
=
[
theirOneTimeKey
dataUsingEncoding
:
NSUTF8StringEncoding
];
NSData
*
otKey
=
[
theirOneTimeKey
dataUsingEncoding
:
NSUTF8StringEncoding
];
size_t
result
=
olm_create_outbound_session
(
_session
,
account
.
account
,
idKey
.
bytes
,
idKey
.
length
,
otKey
.
bytes
,
otKey
.
length
,
random
.
mutableBytes
,
random
.
length
);
size_t
result
=
olm_create_outbound_session
(
_session
,
account
.
account
,
idKey
.
bytes
,
idKey
.
length
,
otKey
.
bytes
,
otKey
.
length
,
random
.
mutableBytes
,
random
.
length
);
[
random
resetBytesInRange
:
NSMakeRange
(
0
,
random
.
length
)];
if
(
result
==
olm_error
())
{
if
(
result
==
olm_error
())
{
const
char
*
olm_error
=
olm_session_last_error
(
_session
);
const
char
*
olm_error
=
olm_session_last_error
(
_session
);
...
@@ -215,6 +216,7 @@
...
@@ -215,6 +216,7 @@
return
nil
;
return
nil
;
}
}
size_t
result
=
olm_encrypt
(
_session
,
plaintextData
.
bytes
,
plaintextData
.
length
,
random
.
mutableBytes
,
random
.
length
,
ciphertext
.
mutableBytes
,
ciphertext
.
length
);
size_t
result
=
olm_encrypt
(
_session
,
plaintextData
.
bytes
,
plaintextData
.
length
,
random
.
mutableBytes
,
random
.
length
,
ciphertext
.
mutableBytes
,
ciphertext
.
length
);
[
random
resetBytesInRange
:
NSMakeRange
(
0
,
random
.
length
)];
if
(
result
==
olm_error
())
{
if
(
result
==
olm_error
())
{
const
char
*
olm_error
=
olm_session_last_error
(
_session
);
const
char
*
olm_error
=
olm_session_last_error
(
_session
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment