Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
44c798fe
Commit
44c798fe
authored
5 years ago
by
arbisoft
Browse files
Options
Downloads
Patches
Plain Diff
Fixing encode/decode issues for python3.
parent
b22f08a4
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/verify_student/models.py
+11
-2
11 additions, 2 deletions
lms/djangoapps/verify_student/models.py
lms/djangoapps/verify_student/ssencrypt.py
+9
-1
9 additions, 1 deletion
lms/djangoapps/verify_student/ssencrypt.py
with
20 additions
and
3 deletions
lms/djangoapps/verify_student/models.py
+
11
−
2
View file @
44c798fe
...
...
@@ -10,6 +10,7 @@ photo verification process as generic as possible.
"""
from
__future__
import
absolute_import
import
codecs
import
functools
import
json
import
logging
...
...
@@ -620,7 +621,11 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
return
aes_key_str
=
settings
.
VERIFY_STUDENT
[
"
SOFTWARE_SECURE
"
][
"
FACE_IMAGE_AES_KEY
"
]
aes_key
=
aes_key_str
.
decode
(
"
hex
"
)
if
six
.
PY3
:
aes_key
=
codecs
.
decode
(
aes_key_str
,
"
hex
"
)
else
:
aes_key
=
aes_key_str
.
decode
(
"
hex
"
)
path
=
self
.
_get_path
(
"
face
"
)
buff
=
ContentFile
(
encrypt_and_encode
(
img_data
,
aes_key
))
...
...
@@ -658,7 +663,11 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
self
.
_storage
.
save
(
path
,
buff
)
# Update our record fields
self
.
photo_id_key
=
rsa_encrypted_aes_key
.
encode
(
'
base64
'
)
if
six
.
PY3
:
self
.
photo_id_key
=
codecs
.
encode
(
rsa_encrypted_aes_key
,
'
base64
'
)
else
:
self
.
photo_id_key
=
rsa_encrypted_aes_key
.
encode
(
'
base64
'
)
self
.
save
()
@status_before_must_be
(
"
must_retry
"
,
"
ready
"
,
"
submitted
"
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/verify_student/ssencrypt.py
+
9
−
1
View file @
44c798fe
...
...
@@ -24,6 +24,7 @@ import logging
import
os
from
hashlib
import
md5
,
sha256
import
six
from
cryptography.hazmat.backends
import
default_backend
from
cryptography.hazmat.primitives
import
serialization
from
cryptography.hazmat.primitives.asymmetric.padding
import
MGF1
,
OAEP
...
...
@@ -83,7 +84,10 @@ def generate_aes_iv(key):
Return the initialization vector Software Secure expects for a given AES
key (they hash it a couple of times and take a substring).
"""
return
md5
(
key
+
md5
(
key
).
hexdigest
()).
hexdigest
()[:
AES_BLOCK_SIZE_BYTES
]
if
six
.
PY3
:
return
md5
(
key
+
md5
(
key
).
hexdigest
().
encode
(
'
utf-8
'
)).
hexdigest
()[:
AES_BLOCK_SIZE_BYTES
].
encode
(
'
utf-8
'
)
else
:
return
md5
(
key
+
md5
(
key
).
hexdigest
()).
hexdigest
()[:
AES_BLOCK_SIZE_BYTES
]
def
random_aes_key
():
...
...
@@ -92,6 +96,10 @@ def random_aes_key():
def
pad
(
data
):
"""
Pad the given `data` such that it fits into the proper AES block size
"""
if
six
.
PY3
:
data
=
six
.
b
(
data
)
padder
=
PKCS7
(
AES
.
block_size
).
padder
()
return
padder
.
update
(
data
)
+
padder
.
finalize
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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