Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
omemo-dr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
gajim
omemo-dr
Commits
ebdcedbc
Commit
ebdcedbc
authored
1 year ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
imprv: Add more validation for bundle
parent
c77baaa2
No related branches found
No related tags found
No related merge requests found
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/omemo_dr/exceptions.py
+4
-0
4 additions, 0 deletions
src/omemo_dr/exceptions.py
src/omemo_dr/state/prekeybundle.py
+12
-2
12 additions, 2 deletions
src/omemo_dr/state/prekeybundle.py
with
16 additions
and
2 deletions
src/omemo_dr/exceptions.py
+
4
−
0
View file @
ebdcedbc
...
@@ -73,3 +73,7 @@ class InvalidMessage(Exception):
...
@@ -73,3 +73,7 @@ class InvalidMessage(Exception):
class
DuplicateMessage
(
Exception
):
class
DuplicateMessage
(
Exception
):
pass
pass
class
BundleValidationError
(
Exception
):
pass
This diff is collapsed.
Click to expand it.
src/omemo_dr/state/prekeybundle.py
+
12
−
2
View file @
ebdcedbc
from
__future__
import
annotations
from
__future__
import
annotations
from
..const
import
MAX_INT
from
..const
import
NS_OMEMO_2
from
..const
import
NS_OMEMO_2
from
..const
import
NS_OMEMO_TMP
from
..const
import
NS_OMEMO_TMP
from
..ecc.djbec
import
CurvePublicKey
from
..ecc.djbec
import
CurvePublicKey
from
..ecc.djbec
import
EdPublicKey
from
..ecc.djbec
import
EdPublicKey
from
..exceptions
import
InvalidKeyException
from
..exceptions
import
BundleValidationError
from
..identitykey
import
IdentityKey
from
..identitykey
import
IdentityKey
from
..structs
import
OMEMOBundleProto
from
..structs
import
OMEMOBundleProto
...
@@ -42,10 +43,19 @@ class PreKeyBundle:
...
@@ -42,10 +43,19 @@ class PreKeyBundle:
elif
ns
==
NS_OMEMO_2
:
elif
ns
==
NS_OMEMO_2
:
ik_pub
=
EdPublicKey
.
from_bytes
(
bundle
.
ik
).
to_curve
()
ik_pub
=
EdPublicKey
.
from_bytes
(
bundle
.
ik
).
to_curve
()
else
:
else
:
raise
InvalidKeyException
(
"
Unknown namespace on bundle: %s
"
,
ns
)
raise
BundleValidationError
(
"
Unknown namespace on bundle: %s
"
,
ns
)
ik
=
IdentityKey
(
ik_pub
)
ik
=
IdentityKey
(
ik_pub
)
if
not
1
<=
bundle
.
device_id
<=
MAX_INT
:
raise
BundleValidationError
(
"
Device id out of range
"
)
if
not
1
<=
prekey
[
"
id
"
]
<=
MAX_INT
:
raise
BundleValidationError
(
"
Prekey id out of range
"
)
if
not
1
<=
bundle
.
spk
[
"
id
"
]
<=
MAX_INT
:
raise
BundleValidationError
(
"
Signed pre key id out of range
"
)
return
cls
(
return
cls
(
bundle
.
device_id
,
bundle
.
device_id
,
bundle
.
namespace
,
bundle
.
namespace
,
...
...
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