Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
gajim-plugins
Commits
25cba9ee
Commit
25cba9ee
authored
5 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
[omemo] Switch to 12 byte IV
parent
dfcc7f49
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
omemo/backend/aes.py
+5
-4
5 additions, 4 deletions
omemo/backend/aes.py
with
5 additions
and
4 deletions
omemo/backend/aes.py
+
5
−
4
View file @
25cba9ee
...
...
@@ -28,6 +28,7 @@ log = logging.getLogger('gajim.p.omemo')
EncryptionResult
=
namedtuple
(
'
EncryptionResult
'
,
'
payload key iv
'
)
IV_SIZE
=
12
def
_decrypt
(
key
,
iv
,
tag
,
data
):
decryptor
=
Cipher
(
...
...
@@ -60,7 +61,7 @@ def aes_decrypt_file(key, iv, payload):
return
_decrypt
(
key
,
iv
,
tag
,
data
)
def
_encrypt
(
data
,
key_size
,
iv_size
):
def
_encrypt
(
data
,
key_size
,
iv_size
=
IV_SIZE
):
if
isinstance
(
data
,
str
):
data
=
data
.
encode
()
key
=
os
.
urandom
(
key_size
)
...
...
@@ -75,13 +76,13 @@ def _encrypt(data, key_size, iv_size):
def
aes_encrypt
(
plaintext
):
key
,
iv
,
tag
,
payload
=
_encrypt
(
plaintext
,
16
,
16
)
key
,
iv
,
tag
,
payload
=
_encrypt
(
plaintext
,
16
)
key
+=
tag
return
EncryptionResult
(
payload
=
payload
,
key
=
key
,
iv
=
iv
)
def
aes_encrypt_file
(
data
):
key
,
iv
,
tag
,
payload
,
=
_encrypt
(
data
,
32
,
16
)
key
,
iv
,
tag
,
payload
,
=
_encrypt
(
data
,
32
)
payload
+=
tag
return
EncryptionResult
(
payload
=
payload
,
key
=
key
,
iv
=
iv
)
...
...
@@ -91,4 +92,4 @@ def get_new_key():
def
get_new_iv
():
return
os
.
urandom
(
16
)
return
os
.
urandom
(
IV_SIZE
)
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