Skip to content

Commit

Permalink
fix: control error invalid encryption part and fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gllm-dev committed Sep 5, 2024
1 parent ef60e7b commit a3457f8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.1.19]
### Fixed
- Control error invalid encryption part
- Fix docs register share endpoint

## [v0.1.18]
### Fixed
- Invalid API authentication message
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Users are automatically associated with a project based on the provided API key.

#### **1.1 Register Share**

- **Endpoint:** `POST /shares/register`
- **Endpoint:** `POST /shares`
- **Request:**
- **Type:** `RegisterShareRequest`
- Mandatory header `Authorization` with access token and `X-API-Key` with project's api key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sssrec

import (
"encoding/base64"

Check failure on line 4 in internal/adapters/encryption/sss_reconstruction_strategy/strategy.go

View workflow job for this annotation

GitHub Actions / Test and Lint

File is not `goimports`-ed (goimports)

sss "go.openfort.xyz/shamir-secret-sharing-go"
"go.openfort.xyz/shield/internal/core/domain/errors"
"go.openfort.xyz/shield/internal/core/ports/strategies"
Expand Down Expand Up @@ -66,6 +65,10 @@ func (s *SSSReconstructionStrategy) Reconstruct(storedPart string, projectPart s
rawProjectPart = append([]byte{2}, rawProjectPart...)
}

if len(rawProjectPart) < 33 {
return "", errors.ErrInvalidEncryptionPart
}

combined, err := sss.Combine([][]byte{rawStoredPart, rawProjectPart})
if err != nil {
return "", err
Expand Down
4 changes: 4 additions & 0 deletions internal/applications/projectapp/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@ func fromDomainError(err error) error {
if errors.Is(err, domainErrors.ErrInvalidEncryptionSession) {
return ErrInvalidEncryptionSession
}

if errors.Is(err, domainErrors.ErrInvalidEncryptionPart) {
return ErrInvalidEncryptionPart
}
return ErrInternal
}
4 changes: 4 additions & 0 deletions internal/applications/shareapp/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func fromDomainError(err error) error {
return ErrEncryptionPartRequired
}

if errors.Is(err, domainErrors.ErrInvalidEncryptionPart) {
return ErrInvalidEncryptionPart
}

if errors.Is(err, domainErrors.ErrEncryptionPartNotFound) {
return ErrEncryptionNotConfigured
}
Expand Down
1 change: 1 addition & 0 deletions internal/core/domain/errors/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var (
ErrEncryptionPartNotFound = errors.New("encryption part not found")
ErrEncryptionPartAlreadyExists = errors.New("encryption part already exists")
ErrEncryptionPartRequired = errors.New("encryption part is required")
ErrInvalidEncryptionPart = errors.New("invalid encryption part")
ErrInvalidEncryptionSession = errors.New("invalid encryption session")
ErrInvalidEncryptionKeyBuilderType = errors.New("invalid encryption key builder type")
ErrReconstructedKeyMismatch = errors.New("reconstructed key mismatch")
Expand Down

0 comments on commit a3457f8

Please sign in to comment.