Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
crypto
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
crypto
Commits
b7f17a51
Commit
b7f17a51
authored
Jan 11, 2023
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Refactor certRequest
parent
067f9f92
No related branches found
No related tags found
2 merge requests
!121
Revert "Propagate moving of rsa/cyclic/hash packages"
,
!93
Remove old RSA from xx.NewId
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
authorize/certRequest.go
+5
-5
5 additions, 5 deletions
authorize/certRequest.go
authorize/certRequest_test.go
+5
-5
5 additions, 5 deletions
authorize/certRequest_test.go
with
10 additions
and
10 deletions
authorize/certRequest.go
+
5
−
5
View file @
b7f17a51
...
...
@@ -10,7 +10,7 @@ package authorize
import
(
"encoding/binary"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/
xx_network/crypto/signature
/rsa"
"gitlab.com/
elixxir/crypto
/rsa"
"io"
"time"
)
...
...
@@ -18,17 +18,17 @@ import (
var
hashType
=
hash
.
CMixHash
// SignCertRequest signs the ACME token & other info sent with an AuthorizerCertRequest
func
SignCertRequest
(
rng
io
.
Reader
,
gwRsa
*
rsa
.
PrivateKey
,
func
SignCertRequest
(
rng
io
.
Reader
,
gwRsa
rsa
.
PrivateKey
,
acmeToken
string
,
now
time
.
Time
)
([]
byte
,
error
)
{
hashed
,
err
:=
hashCertRequestInfo
(
acmeToken
,
now
)
if
err
!=
nil
{
return
nil
,
err
}
return
r
sa
.
Sign
(
rng
,
gwRsa
,
hashType
,
hashed
,
rsa
.
NewDefaultOptions
())
return
gwR
sa
.
Sign
PSS
(
rng
,
hashType
,
hashed
,
rsa
.
NewDefault
PSS
Options
())
}
// VerifyCertRequest verifies the signature on an ACME token & other info sent with an AuthorizerCertRequest
func
VerifyCertRequest
(
gwPub
*
rsa
.
PublicKey
,
sig
[]
byte
,
func
VerifyCertRequest
(
gwPub
rsa
.
PublicKey
,
sig
[]
byte
,
acmeToken
string
,
now
,
signedTS
time
.
Time
,
delta
time
.
Duration
)
error
{
err
:=
checkTimeBound
(
now
,
signedTS
,
delta
)
if
err
!=
nil
{
...
...
@@ -38,7 +38,7 @@ func VerifyCertRequest(gwPub *rsa.PublicKey, sig []byte,
if
err
!=
nil
{
return
err
}
return
rsa
.
Verify
(
gwPub
,
hashType
,
hashed
,
sig
,
rsa
.
NewDefaultOptions
())
return
gwPub
.
Verify
PSS
(
hashType
,
hashed
,
sig
,
rsa
.
NewDefault
PSS
Options
())
}
func
hashCertRequestInfo
(
acmeToken
string
,
timestamp
time
.
Time
)
([]
byte
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
authorize/certRequest_test.go
+
5
−
5
View file @
b7f17a51
...
...
@@ -2,15 +2,15 @@ package authorize
import
(
"bytes"
"gitlab.com/elixxir/crypto/rsa"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/signature/rsa"
"testing"
"time"
)
func
TestSignVerify_CertRequest
(
t
*
testing
.
T
)
{
rng
:=
csprng
.
NewSystemRNG
()
pk
,
err
:=
rsa
.
Generate
Key
(
rng
,
2048
)
pk
,
err
:=
rsa
.
GetScheme
()
.
Generate
(
rng
,
2048
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to generate pk: %+v"
,
err
)
}
...
...
@@ -27,7 +27,7 @@ func TestSignVerify_CertRequest(t *testing.T) {
t
.
Fatalf
(
"Failed to sign acme token"
)
}
err
=
VerifyCertRequest
(
pk
.
Get
Public
(),
sig
,
token
,
testNow
,
timestamp
,
testDelta
)
err
=
VerifyCertRequest
(
pk
.
Public
(),
sig
,
token
,
testNow
,
timestamp
,
testDelta
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to verify signature on acme token: %+v"
,
err
)
}
...
...
@@ -35,7 +35,7 @@ func TestSignVerify_CertRequest(t *testing.T) {
func
TestSignVerify_CertRequest_Consistency
(
t
*
testing
.
T
)
{
rng
:=
&
CountingReader
{
count
:
uint8
(
0
)}
pk
,
err
:=
rsa
.
Generate
Key
(
rng
,
1024
)
pk
,
err
:=
rsa
.
GetScheme
()
.
Generate
(
rng
,
1024
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to generate pk: %+v"
,
err
)
}
...
...
@@ -57,7 +57,7 @@ func TestSignVerify_CertRequest_Consistency(t *testing.T) {
t
.
Fatalf
(
"Failed to verify consistency for SignACMEToken
\n\t
Expected: %+v
\n\t
Received: %+v"
,
expectedSig
,
sig
)
}
err
=
VerifyCertRequest
(
pk
.
Get
Public
(),
sig
,
token
,
testNow
,
timestamp
,
testDelta
)
err
=
VerifyCertRequest
(
pk
.
Public
(),
sig
,
token
,
testNow
,
timestamp
,
testDelta
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to verify signature on acme token: %+v"
,
err
)
}
...
...
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