Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-tink
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-tink
Commits
d2b0705a
Commit
d2b0705a
authored
5 years ago
by
przydatek
Committed by
Charles Lee
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixing memory-access bug.
PiperOrigin-RevId: 243044973 GitOrigin-RevId: 535dc711b71e5f75571755aa0ae85a2fa14ae222
parent
a4f1b0f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cc/aead/kms_envelope_aead.cc
+5
-5
5 additions, 5 deletions
cc/aead/kms_envelope_aead.cc
cc/aead/kms_envelope_aead_test.cc
+2
-2
2 additions, 2 deletions
cc/aead/kms_envelope_aead_test.cc
with
7 additions
and
7 deletions
cc/aead/kms_envelope_aead.cc
+
5
−
5
View file @
d2b0705a
...
...
@@ -108,14 +108,14 @@ util::StatusOr<std::string> KmsEnvelopeAead::Encrypt(
util
::
StatusOr
<
std
::
string
>
KmsEnvelopeAead
::
Decrypt
(
absl
::
string_view
ciphertext
,
absl
::
string_view
associated_data
)
const
{
// Parse the ciphertext.
auto
enc_dek_size
=
BigEndianLoad32
(
reinterpret_cast
<
const
uint8_t
*>
(
ciphertext
.
data
()));
if
(
ciphertext
.
size
()
<
kEncryptedDekPrefixSize
||
enc_dek_size
>
ciphertext
.
size
()
-
kEncryptedDekPrefixSize
)
{
if
(
ciphertext
.
size
()
<
kEncryptedDekPrefixSize
)
{
return
util
::
Status
(
util
::
error
::
INVALID_ARGUMENT
,
"ciphertext too short"
);
}
if
(
enc_dek_size
<
0
)
{
auto
enc_dek_size
=
BigEndianLoad32
(
reinterpret_cast
<
const
uint8_t
*>
(
ciphertext
.
data
()));
if
(
enc_dek_size
>
ciphertext
.
size
()
-
kEncryptedDekPrefixSize
||
enc_dek_size
<
0
)
{
return
util
::
Status
(
util
::
error
::
INVALID_ARGUMENT
,
"invalid ciphertext"
);
}
...
...
This diff is collapsed.
Click to expand it.
cc/aead/kms_envelope_aead_test.cc
+
2
−
2
View file @
d2b0705a
...
...
@@ -107,14 +107,14 @@ TEST(KmsEnvelopeAeadTest, DecryptionErrors) {
HasSubstr
(
"too short"
)));
// Short ciphertext.
decrypt_result
=
aead
->
Decrypt
(
"sh
ort
"
,
aad
);
decrypt_result
=
aead
->
Decrypt
(
"sh"
,
aad
);
EXPECT_THAT
(
decrypt_result
.
status
(),
StatusIs
(
util
::
error
::
INVALID_ARGUMENT
,
HasSubstr
(
"too short"
)));
// Truncated ciphertext.
decrypt_result
=
aead
->
Decrypt
(
ct
.
substr
(
2
),
aad
);
EXPECT_THAT
(
decrypt_result
.
status
(),
StatusIs
(
util
::
error
::
INVALID_ARGUMENT
,
HasSubstr
(
"
too short
"
)));
HasSubstr
(
"
invalid
"
)));
// Corrupted ciphertext.
auto
ct_copy
=
ct
;
...
...
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