Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Julian Dehm
briar
Commits
a8d86a1b
Commit
a8d86a1b
authored
11 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Don't use a byte[1] where a byte will do.
parent
a731b68e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java
+10
-10
10 additions, 10 deletions
briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java
with
10 additions
and
10 deletions
briar-core/src/net/sf/briar/crypto/CryptoComponentImpl.java
+
10
−
10
View file @
a8d86a1b
...
@@ -374,22 +374,22 @@ class CryptoComponentImpl implements CryptoComponent {
...
@@ -374,22 +374,22 @@ class CryptoComponentImpl implements CryptoComponent {
MessageDigest
messageDigest
=
getMessageDigest
();
MessageDigest
messageDigest
=
getMessageDigest
();
if
(
messageDigest
.
getDigestLength
()
<
CIPHER_KEY_BYTES
)
if
(
messageDigest
.
getDigestLength
()
<
CIPHER_KEY_BYTES
)
throw
new
RuntimeException
();
throw
new
RuntimeException
();
// The length of every field must fit in an unsigned 8-bit integer
if
(
rawSecret
.
length
>
255
)
throw
new
IllegalArgumentException
();
if
(
label
.
length
>
255
)
throw
new
IllegalArgumentException
();
if
(
initiatorInfo
.
length
>
255
)
throw
new
IllegalArgumentException
();
if
(
responderInfo
.
length
>
255
)
throw
new
IllegalArgumentException
();
// All fields are length-prefixed
// All fields are length-prefixed
byte
[]
length
=
new
byte
[
1
];
messageDigest
.
update
((
byte
)
rawSecret
.
length
);
ByteUtils
.
writeUint8
(
rawSecret
.
length
,
length
,
0
);
messageDigest
.
update
(
length
);
messageDigest
.
update
(
rawSecret
);
messageDigest
.
update
(
rawSecret
);
ByteUtils
.
writeUint8
(
label
.
length
,
length
,
0
);
messageDigest
.
update
((
byte
)
label
.
length
);
messageDigest
.
update
(
length
);
messageDigest
.
update
(
label
);
messageDigest
.
update
(
label
);
ByteUtils
.
writeUint8
(
initiatorInfo
.
length
,
length
,
0
);
messageDigest
.
update
((
byte
)
initiatorInfo
.
length
);
messageDigest
.
update
(
length
);
messageDigest
.
update
(
initiatorInfo
);
messageDigest
.
update
(
initiatorInfo
);
ByteUtils
.
writeUint8
(
responderInfo
.
length
,
length
,
0
);
messageDigest
.
update
((
byte
)
responderInfo
.
length
);
messageDigest
.
update
(
length
);
messageDigest
.
update
(
responderInfo
);
messageDigest
.
update
(
responderInfo
);
byte
[]
hash
=
messageDigest
.
digest
();
byte
[]
hash
=
messageDigest
.
digest
();
// The secret is the first
SECRET
_KEY_BYTES bytes of the hash
// The secret is the first
CIPHER
_KEY_BYTES bytes of the hash
byte
[]
output
=
new
byte
[
CIPHER_KEY_BYTES
];
byte
[]
output
=
new
byte
[
CIPHER_KEY_BYTES
];
System
.
arraycopy
(
hash
,
0
,
output
,
0
,
output
.
length
);
System
.
arraycopy
(
hash
,
0
,
output
,
0
,
output
.
length
);
ByteUtils
.
erase
(
hash
);
ByteUtils
.
erase
(
hash
);
...
...
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