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
408530ad
Commit
408530ad
authored
Jun 22, 2015
by
Mark Haines
Browse files
Add API for removing used one time keys
parent
fb980849
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/axolotl/account.hh
View file @
408530ad
...
...
@@ -41,6 +41,10 @@ struct Account {
LocalKey
const
*
lookup_key
(
std
::
uint32_t
id
);
std
::
size_t
remove_key
(
std
::
uint32_t
id
);
};
...
...
include/axolotl/axolotl.hh
View file @
408530ad
...
...
@@ -121,6 +121,11 @@ size_t axolotl_matches_inbound_session(
void
*
one_time_key_message
,
size_t
message_length
);
size_t
axolotl_remove_one_time_keys
(
AxolotlAccount
*
account
,
AxolotlSession
*
session
);
size_t
axolotl_encrypt_message_type
(
AxolotlSession
*
session
);
...
...
src/account.cpp
View file @
408530ad
...
...
@@ -11,6 +11,18 @@ axolotl::LocalKey const * axolotl::Account::lookup_key(
return
0
;
}
std
::
size_t
axolotl
::
Account
::
remove_key
(
std
::
uint32_t
id
)
{
LocalKey
*
i
;
for
(
i
=
one_time_keys
.
begin
();
i
!=
one_time_keys
.
end
();
++
i
)
{
if
(
i
->
id
==
id
)
{
one_time_keys
.
erase
(
i
);
return
id
;
}
}
return
std
::
size_t
(
-
1
);
}
std
::
size_t
axolotl
::
Account
::
new_account_random_length
()
{
return
103
*
32
;
...
...
@@ -21,6 +33,7 @@ std::size_t axolotl::Account::new_account(
)
{
if
(
random_length
<
new_account_random_length
())
{
last_error
=
axolotl
::
ErrorCode
::
NOT_ENOUGH_RANDOM
;
return
std
::
size_t
(
-
1
);
}
unsigned
id
=
0
;
...
...
@@ -46,8 +59,6 @@ std::size_t axolotl::Account::new_account(
}
namespace
axolotl
{
...
...
src/axolotl.cpp
View file @
408530ad
...
...
@@ -468,6 +468,20 @@ size_t axolotl_matches_inbound_session(
}
size_t
axolotl_remove_one_time_keys
(
AxolotlAccount
*
account
,
AxolotlSession
*
session
)
{
size_t
result
=
from_c
(
account
)
->
remove_key
(
from_c
(
session
)
->
bob_one_time_key_id
);
if
(
result
==
std
::
size_t
(
-
1
))
{
from_c
(
account
)
->
last_error
=
axolotl
::
ErrorCode
::
BAD_MESSAGE_KEY_ID
;
}
return
result
;
}
size_t
axolotl_encrypt_message_type
(
AxolotlSession
*
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