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
026e4394
Commit
026e4394
authored
Jun 15, 2015
by
Mark Haines
Browse files
Implement creating a new account
parent
6fe3b7eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/axolotl/error.hh
View file @
026e4394
...
...
@@ -11,6 +11,8 @@ enum struct ErrorCode {
BAD_MESSAGE_FORMAT
=
4
,
/*!< The message couldn't be decoded */
BAD_MESSAGE_MAC
=
5
,
/*!< The message couldn't be decrypted */
BAD_MESSAGE_KEY_ID
=
6
,
/*!< The message references an unknown key id */
INVALID_BASE64
=
7
,
/*!< The input base64 was invalid */
BAD_ACCOUNT_KEY
=
8
,
/*!< The supplied account key is invalid */
};
}
// namespace axolotl
...
...
include/axolotl/session.hh
View file @
026e4394
...
...
@@ -14,7 +14,7 @@ struct RemoteKey {
enum
struct
MessageType
{
PRE_KEY
_MESSAGE
=
0
,
PRE_KEY
=
0
,
MESSAGE
=
1
,
};
...
...
src/account.cpp
View file @
026e4394
...
...
@@ -2,7 +2,6 @@
#include "axolotl/pickle.hh"
axolotl
::
LocalKey
const
*
axolotl
::
Account
::
lookup_key
(
std
::
uint32_t
id
)
{
...
...
@@ -12,6 +11,43 @@ axolotl::LocalKey const * axolotl::Account::lookup_key(
return
0
;
}
std
::
size_t
axolotl
::
Account
::
new_account_random_length
()
{
return
103
*
32
;
}
std
::
size_t
axolotl
::
Account
::
new_account
(
uint8_t
const
*
random
,
std
::
size_t
random_length
)
{
if
(
random_length
<
new_account_random_length
())
{
last_error
=
axolotl
::
ErrorCode
::
NOT_ENOUGH_RANDOM
;
}
unsigned
id
=
0
;
identity_key
.
id
=
++
id
;
axolotl
::
generate_key
(
random
,
identity_key
.
key
);
random
+=
32
;
random
+=
32
;
last_resort_one_time_key
.
id
=
++
id
;
axolotl
::
generate_key
(
random
,
last_resort_one_time_key
.
key
);
random
+=
32
;
for
(
unsigned
i
=
0
;
i
<
100
;
++
i
)
{
LocalKey
&
key
=
*
one_time_keys
.
insert
(
one_time_keys
.
end
());
key
.
id
=
++
id
;
axolotl
::
generate_key
(
random
,
key
.
key
);
random
+=
32
;
}
return
0
;
}
namespace
axolotl
{
...
...
@@ -72,7 +108,7 @@ static std::uint8_t const * unpickle(
}
// namespace axolotl
std
::
size_t
pickle_length
(
std
::
size_t
axolotl
::
pickle_length
(
axolotl
::
Account
const
&
value
)
{
std
::
size_t
length
=
0
;
...
...
@@ -83,7 +119,7 @@ std::size_t pickle_length(
}
std
::
uint8_t
*
pickle
(
std
::
uint8_t
*
axolotl
::
pickle
(
std
::
uint8_t
*
pos
,
axolotl
::
Account
const
&
value
)
{
...
...
@@ -94,7 +130,7 @@ std::uint8_t * pickle(
}
std
::
uint8_t
const
*
unpickle
(
std
::
uint8_t
const
*
axolotl
::
unpickle
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
axolotl
::
Account
&
value
)
{
...
...
src/session.cpp
View file @
026e4394
...
...
@@ -190,7 +190,7 @@ axolotl::MessageType axolotl::Session::encrypt_message_type() {
if
(
received_message
)
{
return
axolotl
::
MessageType
::
MESSAGE
;
}
else
{
return
axolotl
::
MessageType
::
PRE_KEY
_MESSAGE
;
return
axolotl
::
MessageType
::
PRE_KEY
;
}
}
...
...
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