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
4e57029d
Commit
4e57029d
authored
10 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Use constant-time GCM multiplier.
parent
ed79719b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
briar-api/src/org/briarproject/api/crypto/CryptoComponent.java
+1
-1
1 addition, 1 deletion
...-api/src/org/briarproject/api/crypto/CryptoComponent.java
briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java
+9
-7
9 additions, 7 deletions
...core/src/org/briarproject/crypto/CryptoComponentImpl.java
with
10 additions
and
8 deletions
briar-api/src/org/briarproject/api/crypto/CryptoComponent.java
+
1
−
1
View file @
4e57029d
...
...
@@ -65,7 +65,7 @@ public interface CryptoComponent {
/**
* Derives a tag key from the given temporary secret.
* @param alice indicates whether the key is for
connection
s initiated by
* @param alice indicates whether the key is for
stream
s initiated by
* Alice or Bob.
*/
SecretKey
deriveTagKey
(
byte
[]
secret
,
boolean
alice
);
...
...
This diff is collapsed.
Click to expand it.
briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java
+
9
−
7
View file @
4e57029d
...
...
@@ -43,6 +43,7 @@ import org.spongycastle.crypto.generators.PKCS5S2ParametersGenerator;
import
org.spongycastle.crypto.macs.HMac
;
import
org.spongycastle.crypto.modes.AEADBlockCipher
;
import
org.spongycastle.crypto.modes.GCMBlockCipher
;
import
org.spongycastle.crypto.modes.gcm.BasicGCMMultiplier
;
import
org.spongycastle.crypto.params.ECKeyGenerationParameters
;
import
org.spongycastle.crypto.params.ECPrivateKeyParameters
;
import
org.spongycastle.crypto.params.ECPublicKeyParameters
;
...
...
@@ -294,7 +295,12 @@ class CryptoComponentImpl implements CryptoComponent {
}
public
AuthenticatedCipher
getFrameCipher
()
{
AEADBlockCipher
a
=
new
GCMBlockCipher
(
new
AESLightEngine
());
return
getAuthenticatedCipher
();
}
private
AuthenticatedCipher
getAuthenticatedCipher
()
{
AEADBlockCipher
a
=
new
GCMBlockCipher
(
new
AESLightEngine
(),
new
BasicGCMMultiplier
());
return
new
AuthenticatedCipherImpl
(
a
,
MAC_BYTES
);
}
...
...
@@ -329,10 +335,8 @@ class CryptoComponentImpl implements CryptoComponent {
ByteUtils
.
writeUint32
(
iterations
,
output
,
salt
.
length
);
System
.
arraycopy
(
iv
,
0
,
output
,
salt
.
length
+
4
,
iv
.
length
);
// Initialise the cipher and encrypt the plaintext
AuthenticatedCipher
cipher
=
getAuthenticatedCipher
();
try
{
AEADBlockCipher
a
=
new
GCMBlockCipher
(
new
AESLightEngine
());
AuthenticatedCipher
cipher
=
new
AuthenticatedCipherImpl
(
a
,
MAC_BYTES
);
cipher
.
init
(
true
,
key
,
iv
,
null
);
int
outputOff
=
salt
.
length
+
4
+
iv
.
length
;
cipher
.
process
(
input
,
0
,
input
.
length
,
output
,
outputOff
);
...
...
@@ -356,10 +360,8 @@ class CryptoComponentImpl implements CryptoComponent {
// Derive the key from the password
SecretKey
key
=
new
SecretKey
(
pbkdf2
(
password
,
salt
,
(
int
)
iterations
));
// Initialise the cipher
AuthenticatedCipher
cipher
;
AuthenticatedCipher
cipher
=
getAuthenticatedCipher
()
;
try
{
AEADBlockCipher
a
=
new
GCMBlockCipher
(
new
AESLightEngine
());
cipher
=
new
AuthenticatedCipherImpl
(
a
,
MAC_BYTES
);
cipher
.
init
(
false
,
key
,
iv
,
null
);
}
catch
(
GeneralSecurityException
e
)
{
throw
new
RuntimeException
(
e
);
...
...
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