-
Notifications
You must be signed in to change notification settings - Fork 39
feat: add PKI HSM option #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
carlosmonastyrski
wants to merge
1
commit into
main
Choose a base branch
from
feat/hsm-pkcs11-handler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package gatewayv2 | ||
|
|
||
| type Pkcs11Module interface { | ||
| Test(slotLabel string, pin []byte) (SlotInfo, error) | ||
|
|
||
| GenerateKeyPair(slotLabel string, pin []byte, keyLabel string, keyAlgorithm string) ([]byte, error) | ||
|
|
||
| GetPublicKey(slotLabel string, pin []byte, keyLabel string) ([]byte, error) | ||
|
|
||
| Sign(slotLabel string, pin []byte, keyLabel string, mechanism string, data []byte, isDigest bool) ([]byte, error) | ||
|
|
||
| Finalize() error | ||
| } | ||
|
|
||
| type SlotInfo struct { | ||
| Manufacturer string `json:"manufacturer"` | ||
| Model string `json:"model"` | ||
| Firmware string `json:"firmware"` | ||
| } | ||
|
|
||
| type Pkcs11ErrorCode string | ||
|
|
||
| const ( | ||
| Pkcs11ErrPinIncorrect Pkcs11ErrorCode = "pin_incorrect" | ||
| Pkcs11ErrPinLocked Pkcs11ErrorCode = "pin_locked" | ||
| Pkcs11ErrSlotNotFound Pkcs11ErrorCode = "slot_not_found" | ||
| Pkcs11ErrKeyNotFound Pkcs11ErrorCode = "key_not_found" | ||
| Pkcs11ErrMechanismInvalid Pkcs11ErrorCode = "mechanism_invalid" | ||
| Pkcs11ErrDriverUnavailable Pkcs11ErrorCode = "driver_unavailable" | ||
| Pkcs11ErrLoginFailed Pkcs11ErrorCode = "login_failed" | ||
| Pkcs11ErrNotSupported Pkcs11ErrorCode = "pkcs11_not_supported" | ||
| Pkcs11ErrBadRequest Pkcs11ErrorCode = "bad_request" | ||
| Pkcs11ErrInternal Pkcs11ErrorCode = "internal" | ||
| ) | ||
|
|
||
| type Pkcs11Error struct { | ||
| Code Pkcs11ErrorCode | ||
| Message string | ||
| } | ||
|
|
||
| func (e *Pkcs11Error) Error() string { | ||
| return string(e.Code) + ": " + e.Message | ||
| } | ||
|
|
||
| // Supported keyAlgorithm values. | ||
| const ( | ||
| KeyAlgorithmRSA2048 = "RSA_2048" | ||
| KeyAlgorithmRSA4096 = "RSA_4096" | ||
| KeyAlgorithmECCP256 = "ECC_P256" | ||
| KeyAlgorithmECCP384 = "ECC_P384" | ||
| ) | ||
|
|
||
| const CapabilityPkcs11 = "pkcs11" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //go:build !pkcs11 | ||
|
|
||
| package gatewayv2 | ||
|
|
||
| func LoadPkcs11Module(_ string) (Pkcs11Module, error) { | ||
| return nil, &Pkcs11Error{ | ||
| Code: Pkcs11ErrNotSupported, | ||
| Message: "This Gateway build was compiled without PKCS#11 support. Use the infisical-pkcs11 release artifact, or build from source with `go build -tags pkcs11` (cgo + dynamic linking required).", | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.