Skip to content

Commit

Permalink
Refactor vault logic
Browse files Browse the repository at this point in the history
  • Loading branch information
J3imip committed Dec 23, 2024
1 parent 60537d3 commit e554b7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion internal/config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Keys struct {
}

type KeysConfig struct {
SignatureKey *ecdsa.PrivateKey `fig:"signature_key,required"`
SignatureKey *ecdsa.PrivateKey `fig:"signature_key"`
}

func (e *Keys) KeysConfig() KeysConfig {
Expand Down
5 changes: 2 additions & 3 deletions internal/config/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ type VaultConfiger interface {
}

type VaultConfig struct {
MountPath string `json:"VAULT_MOUNT_PATH"`
PrivateKeyPath string `json:"VAULT_PRIVATE_KEY_PATH"`
SecretPath string `json:"VAULT_SECRET_PATH"`
MountPath string `json:"VAULT_MOUNT_PATH"`
SecretPath string `json:"VAULT_SECRET_PATH"`
}

type ClientKeysCredentialsConfig struct {
Expand Down
26 changes: 13 additions & 13 deletions internal/service/api/handlers/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ func Register(w http.ResponseWriter, r *http.Request) {
}

func verifySod(
signedAttributes []byte,
encapsulatedContent []byte,
signature []byte,
cert *x509.Certificate,
algorithmPair types.AlgorithmPair,
cfg *config.VerifierConfig,
signedAttributes []byte,
encapsulatedContent []byte,
signature []byte,
cert *x509.Certificate,
algorithmPair types.AlgorithmPair,
cfg *config.VerifierConfig,
) error {
if err := validateSignedAttributes(signedAttributes, encapsulatedContent, algorithmPair.HashAlgorithm); err != nil {
return &types.SodError{
Expand Down Expand Up @@ -397,9 +397,9 @@ func parseCertificate(pemFile []byte) (*x509.Certificate, error) {
}

func validateSignedAttributes(
signedAttributes,
encapsulatedContent []byte,
hashAlgorithm types.HashAlgorithm,
signedAttributes,
encapsulatedContent []byte,
hashAlgorithm types.HashAlgorithm,
) error {
signedAttributesASN1 := make([]asn1.RawValue, 0)

Expand Down Expand Up @@ -437,10 +437,10 @@ func validateSignedAttributes(
}

func verifySignature(
signature []byte,
cert *x509.Certificate,
signedAttributes []byte,
algorithmPair types.AlgorithmPair,
signature []byte,
cert *x509.Certificate,
signedAttributes []byte,
algorithmPair types.AlgorithmPair,
) error {
h := types.GeneralHash(algorithmPair.HashAlgorithm)
h.Write(signedAttributes)
Expand Down
1 change: 1 addition & 0 deletions internal/utils/asn1_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestTruncateDg1Hash(t *testing.T) {
return result
}(),
},

}

for _, tt := range tests {
Expand Down

0 comments on commit e554b7c

Please sign in to comment.