Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Olm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Olm
Commits
159faa1e
Commit
159faa1e
authored
9 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
Make the internal functions static, remove some unused internal functions
parent
c35d1d42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/account.cpp
+6
-40
6 additions, 40 deletions
src/account.cpp
src/crypto.cpp
+2
-2
2 additions, 2 deletions
src/crypto.cpp
src/message.cpp
+10
-10
10 additions, 10 deletions
src/message.cpp
src/ratchet.cpp
+6
-6
6 additions, 6 deletions
src/ratchet.cpp
src/session.cpp
+1
-1
1 addition, 1 deletion
src/session.cpp
with
25 additions
and
59 deletions
src/account.cpp
+
6
−
40
View file @
159faa1e
...
...
@@ -69,26 +69,11 @@ std::size_t olm::Account::new_account(
namespace
{
namespace
{
uint8_t
KEY_JSON_ED25519
[]
=
"
\"
ed25519
\"
:"
;
uint8_t
KEY_JSON_CURVE25519
[]
=
"
\"
curve25519
\"
:"
;
}
std
::
size_t
count_digits
(
std
::
uint64_t
value
)
{
std
::
size_t
digits
=
0
;
do
{
digits
++
;
value
/=
10
;
}
while
(
value
);
return
digits
;
}
template
<
typename
T
>
std
::
uint8_t
*
write_string
(
static
std
::
uint8_t
*
write_string
(
std
::
uint8_t
*
pos
,
T
const
&
value
)
{
...
...
@@ -96,27 +81,6 @@ std::uint8_t * write_string(
return
pos
+
(
sizeof
(
T
)
-
1
);
}
std
::
uint8_t
*
write_string
(
std
::
uint8_t
*
pos
,
std
::
uint8_t
const
*
value
,
std
::
size_t
value_length
)
{
std
::
memcpy
(
pos
,
value
,
value_length
);
return
pos
+
value_length
;
}
std
::
uint8_t
*
write_digits
(
std
::
uint8_t
*
pos
,
std
::
uint64_t
value
)
{
size_t
digits
=
count_digits
(
value
);
pos
+=
digits
;
do
{
*
(
--
pos
)
=
'0'
+
(
value
%
10
);
value
/=
10
;
}
while
(
value
);
return
pos
+
digits
;
}
}
...
...
@@ -196,19 +160,20 @@ std::size_t olm::Account::sign(
std
::
size_t
olm
::
Account
::
get_one_time_keys_json_length
(
)
{
std
::
size_t
length
=
0
;
bool
is_empty
=
true
;
for
(
auto
const
&
key
:
one_time_keys
)
{
if
(
key
.
published
)
{
continue
;
}
is_empty
=
false
;
length
+=
2
;
/* {" */
length
+=
olm
::
encode_base64_length
(
olm
::
pickle_length
(
key
.
id
));
length
+=
3
;
/* ":" */
length
+=
olm
::
encode_base64_length
(
sizeof
(
key
.
key
.
public_key
));
length
+=
1
;
/* " */
}
if
(
length
==
0
)
{
/* The list was empty. Add a byte for the opening '{' */
length
=
1
;
if
(
is_empty
)
{
length
+=
1
;
/* { */
}
length
+=
3
;
/* }{} */
length
+=
sizeof
(
KEY_JSON_CURVE25519
)
-
1
;
...
...
@@ -244,6 +209,7 @@ std::size_t olm::Account::get_one_time_keys_json(
sep
=
','
;
}
if
(
sep
!=
','
)
{
/* The list was empty */
*
(
pos
++
)
=
sep
;
}
*
(
pos
++
)
=
'}'
;
...
...
This diff is collapsed.
Click to expand it.
src/crypto.cpp
+
2
−
2
View file @
159faa1e
...
...
@@ -99,7 +99,7 @@ inline static void hmac_sha256_key(
}
inline
void
hmac_sha256_init
(
inline
static
void
hmac_sha256_init
(
::
SHA256_CTX
*
context
,
std
::
uint8_t
const
*
hmac_key
)
{
...
...
@@ -114,7 +114,7 @@ inline void hmac_sha256_init(
}
inline
void
hmac_sha256_final
(
inline
static
void
hmac_sha256_final
(
::
SHA256_CTX
*
context
,
std
::
uint8_t
const
*
hmac_key
,
std
::
uint8_t
*
output
...
...
This diff is collapsed.
Click to expand it.
src/message.cpp
+
10
−
10
View file @
159faa1e
...
...
@@ -17,7 +17,7 @@
namespace
{
template
<
typename
T
>
std
::
size_t
varint_length
(
static
std
::
size_t
varint_length
(
T
value
)
{
std
::
size_t
result
=
1
;
...
...
@@ -30,7 +30,7 @@ std::size_t varint_length(
template
<
typename
T
>
std
::
uint8_t
*
varint_encode
(
static
std
::
uint8_t
*
varint_encode
(
std
::
uint8_t
*
output
,
T
value
)
{
...
...
@@ -44,7 +44,7 @@ std::uint8_t * varint_encode(
template
<
typename
T
>
T
varint_decode
(
static
T
varint_decode
(
std
::
uint8_t
const
*
varint_start
,
std
::
uint8_t
const
*
varint_end
)
{
...
...
@@ -60,7 +60,7 @@ T varint_decode(
}
std
::
uint8_t
const
*
varint_skip
(
static
std
::
uint8_t
const
*
varint_skip
(
std
::
uint8_t
const
*
input
,
std
::
uint8_t
const
*
input_end
)
{
...
...
@@ -74,7 +74,7 @@ std::uint8_t const * varint_skip(
}
std
::
size_t
varstring_length
(
static
std
::
size_t
varstring_length
(
std
::
size_t
string_length
)
{
return
varint_length
(
string_length
)
+
string_length
;
...
...
@@ -85,7 +85,7 @@ static std::uint8_t const RATCHET_KEY_TAG = 012;
static
std
::
uint8_t
const
COUNTER_TAG
=
020
;
static
std
::
uint8_t
const
CIPHERTEXT_TAG
=
042
;
std
::
uint8_t
*
encode
(
static
std
::
uint8_t
*
encode
(
std
::
uint8_t
*
pos
,
std
::
uint8_t
tag
,
std
::
uint32_t
value
...
...
@@ -94,7 +94,7 @@ std::uint8_t * encode(
return
varint_encode
(
pos
,
value
);
}
std
::
uint8_t
*
encode
(
static
std
::
uint8_t
*
encode
(
std
::
uint8_t
*
pos
,
std
::
uint8_t
tag
,
std
::
uint8_t
*
&
value
,
std
::
size_t
value_length
...
...
@@ -105,7 +105,7 @@ std::uint8_t * encode(
return
pos
+
value_length
;
}
std
::
uint8_t
const
*
decode
(
static
std
::
uint8_t
const
*
decode
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
std
::
uint8_t
tag
,
std
::
uint32_t
&
value
,
bool
&
has_value
...
...
@@ -121,7 +121,7 @@ std::uint8_t const * decode(
}
std
::
uint8_t
const
*
decode
(
static
std
::
uint8_t
const
*
decode
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
std
::
uint8_t
tag
,
std
::
uint8_t
const
*
&
value
,
std
::
size_t
&
value_length
...
...
@@ -139,7 +139,7 @@ std::uint8_t const * decode(
return
pos
;
}
std
::
uint8_t
const
*
skip_unknown
(
static
std
::
uint8_t
const
*
skip_unknown
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
)
{
if
(
pos
!=
end
)
{
...
...
This diff is collapsed.
Click to expand it.
src/ratchet.cpp
+
6
−
6
View file @
159faa1e
...
...
@@ -29,7 +29,7 @@ std::uint8_t MESSAGE_KEY_SEED[1] = {0x01};
std
::
uint8_t
CHAIN_KEY_SEED
[
1
]
=
{
0x02
};
std
::
size_t
MAX_MESSAGE_GAP
=
2000
;
void
create_chain_key
(
static
void
create_chain_key
(
olm
::
SharedKey
const
&
root_key
,
olm
::
Curve25519KeyPair
const
&
our_key
,
olm
::
Curve25519PublicKey
const
&
their_key
,
...
...
@@ -54,7 +54,7 @@ void create_chain_key(
}
void
advance_chain_key
(
static
void
advance_chain_key
(
olm
::
ChainKey
const
&
chain_key
,
olm
::
ChainKey
&
new_chain_key
)
{
...
...
@@ -67,7 +67,7 @@ void advance_chain_key(
}
void
create_message_keys
(
static
void
create_message_keys
(
olm
::
ChainKey
const
&
chain_key
,
olm
::
KdfInfo
const
&
info
,
olm
::
MessageKey
&
message_key
...
...
@@ -81,7 +81,7 @@ void create_message_keys(
}
std
::
size_t
verify_mac_and_decrypt
(
static
std
::
size_t
verify_mac_and_decrypt
(
olm
::
Cipher
const
&
cipher
,
olm
::
MessageKey
const
&
message_key
,
olm
::
MessageReader
const
&
reader
,
...
...
@@ -96,7 +96,7 @@ std::size_t verify_mac_and_decrypt(
}
std
::
size_t
verify_mac_and_decrypt_for_existing_chain
(
static
std
::
size_t
verify_mac_and_decrypt_for_existing_chain
(
olm
::
Ratchet
const
&
session
,
olm
::
ChainKey
const
&
chain
,
olm
::
MessageReader
const
&
reader
,
...
...
@@ -130,7 +130,7 @@ std::size_t verify_mac_and_decrypt_for_existing_chain(
}
std
::
size_t
verify_mac_and_decrypt_for_new_chain
(
static
std
::
size_t
verify_mac_and_decrypt_for_new_chain
(
olm
::
Ratchet
const
&
session
,
olm
::
MessageReader
const
&
reader
,
std
::
uint8_t
*
plaintext
,
std
::
size_t
max_plaintext_length
...
...
This diff is collapsed.
Click to expand it.
src/session.cpp
+
1
−
1
View file @
159faa1e
...
...
@@ -101,7 +101,7 @@ std::size_t olm::Session::new_outbound_session(
namespace
{
bool
check_message_fields
(
static
bool
check_message_fields
(
olm
::
PreKeyMessageReader
&
reader
,
bool
have_their_identity_key
)
{
bool
ok
=
true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment