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
833ecd3c
Commit
833ecd3c
authored
8 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Convert ed25519 pickling functions to C
... so that I can use them from the group session bits.
parent
c09aa77c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/olm/pickle.h
+40
-0
40 additions, 0 deletions
include/olm/pickle.h
include/olm/pickle.hh
+0
-34
0 additions, 34 deletions
include/olm/pickle.hh
src/account.cpp
+4
-3
4 additions, 3 deletions
src/account.cpp
src/pickle.cpp
+27
-28
27 additions, 28 deletions
src/pickle.cpp
with
71 additions
and
65 deletions
include/olm/pickle.h
+
40
−
0
View file @
833ecd3c
...
...
@@ -21,6 +21,10 @@
extern
"C"
{
#endif
struct
_olm_ed25519_public_key
;
struct
_olm_ed25519_key_pair
;
#define _olm_pickle_uint32_length(value) 4
uint8_t
*
_olm_pickle_uint32
(
uint8_t
*
pos
,
uint32_t
value
);
uint8_t
const
*
_olm_unpickle_uint32
(
...
...
@@ -43,6 +47,42 @@ uint8_t const * _olm_unpickle_bytes(uint8_t const * pos, uint8_t const * end,
uint8_t
*
bytes
,
size_t
bytes_length
);
/** Get the number of bytes needed to pickle an ed25519 public key */
size_t
_olm_pickle_ed25519_public_key_length
(
const
struct
_olm_ed25519_public_key
*
value
);
/** Pickle the ed25519 public key. Returns a pointer to the next free space in
* the buffer. */
uint8_t
*
_olm_pickle_ed25519_public_key
(
uint8_t
*
pos
,
const
struct
_olm_ed25519_public_key
*
value
);
/** Unpickle the ed25519 public key. Returns a pointer to the next item in the
* buffer. */
const
uint8_t
*
_olm_unpickle_ed25519_public_key
(
const
uint8_t
*
pos
,
const
uint8_t
*
end
,
struct
_olm_ed25519_public_key
*
value
);
/** Get the number of bytes needed to pickle an ed25519 key pair */
size_t
_olm_pickle_ed25519_key_pair_length
(
const
struct
_olm_ed25519_key_pair
*
value
);
/** Pickle the ed25519 key pair. Returns a pointer to the next free space in
* the buffer. */
uint8_t
*
_olm_pickle_ed25519_key_pair
(
uint8_t
*
pos
,
const
struct
_olm_ed25519_key_pair
*
value
);
/** Unpickle the ed25519 key pair. Returns a pointer to the next item in the
* buffer. */
const
uint8_t
*
_olm_unpickle_ed25519_key_pair
(
const
uint8_t
*
pos
,
const
uint8_t
*
end
,
struct
_olm_ed25519_key_pair
*
value
);
#ifdef __cplusplus
}
// extern "C"
#endif
...
...
This diff is collapsed.
Click to expand it.
include/olm/pickle.hh
+
0
−
34
View file @
833ecd3c
...
...
@@ -141,40 +141,6 @@ std::uint8_t const * unpickle(
_olm_curve25519_key_pair
&
value
);
std
::
size_t
pickle_length
(
const
_olm_ed25519_public_key
&
value
);
std
::
uint8_t
*
pickle
(
std
::
uint8_t
*
pos
,
const
_olm_ed25519_public_key
&
value
);
std
::
uint8_t
const
*
unpickle
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
_olm_ed25519_public_key
&
value
);
std
::
size_t
pickle_length
(
const
_olm_ed25519_key_pair
&
value
);
std
::
uint8_t
*
pickle
(
std
::
uint8_t
*
pos
,
const
_olm_ed25519_key_pair
&
value
);
std
::
uint8_t
const
*
unpickle
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
_olm_ed25519_key_pair
&
value
);
}
// namespace olm
...
...
This diff is collapsed.
Click to expand it.
src/account.cpp
+
4
−
3
View file @
833ecd3c
...
...
@@ -14,6 +14,7 @@
*/
#include
"olm/account.hh"
#include
"olm/base64.hh"
#include
"olm/pickle.h"
#include
"olm/pickle.hh"
#include
"olm/memory.hh"
...
...
@@ -265,7 +266,7 @@ static std::size_t pickle_length(
olm
::
IdentityKeys
const
&
value
)
{
size_t
length
=
0
;
length
+=
olm
::
pickle_length
(
value
.
ed25519_key
);
length
+=
_
olm
_
pickle_
ed25519_key_pair_
length
(
&
value
.
ed25519_key
);
length
+=
olm
::
pickle_length
(
value
.
curve25519_key
);
return
length
;
}
...
...
@@ -275,7 +276,7 @@ static std::uint8_t * pickle(
std
::
uint8_t
*
pos
,
olm
::
IdentityKeys
const
&
value
)
{
pos
=
olm
::
pickle
(
pos
,
value
.
ed25519_key
);
pos
=
_
olm
_
pickle
_ed25519_key_pair
(
pos
,
&
value
.
ed25519_key
);
pos
=
olm
::
pickle
(
pos
,
value
.
curve25519_key
);
return
pos
;
}
...
...
@@ -285,7 +286,7 @@ static std::uint8_t const * unpickle(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
olm
::
IdentityKeys
&
value
)
{
pos
=
olm
::
unpickle
(
pos
,
end
,
value
.
ed25519_key
);
pos
=
_
olm
_
unpickle
_ed25519_key_pair
(
pos
,
end
,
&
value
.
ed25519_key
);
pos
=
olm
::
unpickle
(
pos
,
end
,
value
.
curve25519_key
);
return
pos
;
}
...
...
This diff is collapsed.
Click to expand it.
src/pickle.cpp
+
27
−
28
View file @
833ecd3c
...
...
@@ -139,77 +139,76 @@ std::uint8_t const * olm::unpickle(
return
pos
;
}
std
::
size_t
olm
::
pickle_length
(
const
_olm_ed25519_public_key
&
value
////// pickle.h implementations
std
::
size_t
_olm_pickle_ed25519_public_key_length
(
const
_olm_ed25519_public_key
*
value
)
{
return
sizeof
(
value
.
public_key
);
return
sizeof
(
value
->
public_key
);
}
std
::
uint8_t
*
olm
::
pickle
(
std
::
uint8_t
*
_
olm
_
pickle
_ed25519_public_key
(
std
::
uint8_t
*
pos
,
const
_olm_ed25519_public_key
&
value
const
_olm_ed25519_public_key
*
value
)
{
pos
=
olm
::
pickle_bytes
(
pos
,
value
.
public_key
,
sizeof
(
value
.
public_key
)
pos
,
value
->
public_key
,
sizeof
(
value
->
public_key
)
);
return
pos
;
}
std
::
uint8_t
const
*
olm
::
unpickle
(
std
::
uint8_t
const
*
_
olm
_
unpickle
_ed25519_public_key
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
_olm_ed25519_public_key
&
value
_olm_ed25519_public_key
*
value
)
{
pos
=
olm
::
unpickle_bytes
(
pos
,
end
,
value
.
public_key
,
sizeof
(
value
.
public_key
)
pos
,
end
,
value
->
public_key
,
sizeof
(
value
->
public_key
)
);
return
pos
;
}
std
::
size_t
olm
::
pickle_length
(
const
_olm_ed25519_key_pair
&
value
std
::
size_t
_
olm
_
pickle_
ed25519_key_pair_
length
(
const
_olm_ed25519_key_pair
*
value
)
{
return
sizeof
(
value
.
public_key
.
public_key
)
+
sizeof
(
value
.
private_key
.
private_key
);
return
sizeof
(
value
->
public_key
.
public_key
)
+
sizeof
(
value
->
private_key
.
private_key
);
}
std
::
uint8_t
*
olm
::
pickle
(
std
::
uint8_t
*
_
olm
_
pickle
_ed25519_key_pair
(
std
::
uint8_t
*
pos
,
const
_olm_ed25519_key_pair
&
value
const
_olm_ed25519_key_pair
*
value
)
{
pos
=
olm
::
pickle_bytes
(
pos
,
value
.
public_key
.
public_key
,
sizeof
(
value
.
public_key
.
public_key
)
pos
,
value
->
public_key
.
public_key
,
sizeof
(
value
->
public_key
.
public_key
)
);
pos
=
olm
::
pickle_bytes
(
pos
,
value
.
private_key
.
private_key
,
sizeof
(
value
.
private_key
.
private_key
)
pos
,
value
->
private_key
.
private_key
,
sizeof
(
value
->
private_key
.
private_key
)
);
return
pos
;
}
std
::
uint8_t
const
*
olm
::
unpickle
(
std
::
uint8_t
const
*
_
olm
_
unpickle
_ed25519_key_pair
(
std
::
uint8_t
const
*
pos
,
std
::
uint8_t
const
*
end
,
_olm_ed25519_key_pair
&
value
_olm_ed25519_key_pair
*
value
)
{
pos
=
olm
::
unpickle_bytes
(
pos
,
end
,
value
.
public_key
.
public_key
,
sizeof
(
value
.
public_key
.
public_key
)
pos
,
end
,
value
->
public_key
.
public_key
,
sizeof
(
value
->
public_key
.
public_key
)
);
pos
=
olm
::
unpickle_bytes
(
pos
,
end
,
value
.
private_key
.
private_key
,
sizeof
(
value
.
private_key
.
private_key
)
pos
,
end
,
value
->
private_key
.
private_key
,
sizeof
(
value
->
private_key
.
private_key
)
);
return
pos
;
}
////// pickle.h implementations
uint8_t
*
_olm_pickle_uint32
(
uint8_t
*
pos
,
uint32_t
value
)
{
return
olm
::
pickle
(
pos
,
value
);
}
...
...
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