rest

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KeyStoreVarName = "keystore"

	BaseV1Path      = "/v1"
	KeyStorePath    = BaseV1Path + "/keystores"
	DIDPath         = KeyStorePath + "/did"
	KeyPath         = KeyStorePath + "/{" + KeyStoreVarName + "}/keys"
	ExportKeyPath   = KeyPath + "/{" + keyVarName + "}/export"
	RotateKeyPath   = KeyPath + "/{" + keyVarName + "}/rotate"
	SignPath        = KeyPath + "/{" + keyVarName + "}/sign"
	VerifyPath      = KeyPath + "/{" + keyVarName + "}/verify"
	EncryptPath     = KeyPath + "/{" + keyVarName + "}/encrypt"
	DecryptPath     = KeyPath + "/{" + keyVarName + "}/decrypt"
	ComputeMACPath  = KeyPath + "/{" + keyVarName + "}/computemac"
	VerifyMACPath   = KeyPath + "/{" + keyVarName + "}/verifymac"
	SignMultiPath   = KeyPath + "/{" + keyVarName + "}/signmulti"
	VerifyMultiPath = KeyPath + "/{" + keyVarName + "}/verifymulti"
	DeriveProofPath = KeyPath + "/{" + keyVarName + "}/deriveproof"
	VerifyProofPath = KeyPath + "/{" + keyVarName + "}/verifyproof"
	EasyPath        = KeyPath + "/{" + keyVarName + "}/easy"
	EasyOpenPath    = KeyStorePath + "/{" + KeyStoreVarName + "}/easyopen"
	SealOpenPath    = KeyStorePath + "/{" + KeyStoreVarName + "}/sealopen"
	WrapKeyPath     = KeyStorePath + "/{" + KeyStoreVarName + "}/wrap"
	WrapKeyAEPath   = KeyPath + "/{" + keyVarName + "}/wrap"
	UnwrapKeyPath   = KeyPath + "/{" + keyVarName + "}/unwrap"
	HealthCheckPath = "/healthcheck"
)

API endpoints.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd interface {
	CreateDID(w io.Writer, r io.Reader) error
	CreateKeyStore(w io.Writer, r io.Reader) error
	CreateKey(w io.Writer, r io.Reader) error
	ExportKey(w io.Writer, r io.Reader) error
	RotateKey(w io.Writer, r io.Reader) error
	ImportKey(w io.Writer, r io.Reader) error
	Sign(w io.Writer, r io.Reader) error
	Verify(w io.Writer, r io.Reader) error
	Encrypt(w io.Writer, r io.Reader) error
	Decrypt(w io.Writer, r io.Reader) error
	ComputeMAC(w io.Writer, r io.Reader) error
	VerifyMAC(w io.Writer, r io.Reader) error
	SignMulti(w io.Writer, r io.Reader) error
	VerifyMulti(w io.Writer, r io.Reader) error
	DeriveProof(w io.Writer, r io.Reader) error
	VerifyProof(w io.Writer, r io.Reader) error
	Easy(w io.Writer, r io.Reader) error
	EasyOpen(w io.Writer, r io.Reader) error
	SealOpen(w io.Writer, r io.Reader) error
	WrapKey(w io.Writer, r io.Reader) error
	UnwrapKey(w io.Writer, r io.Reader) error
}

Cmd defines command methods.

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse is an error response model.

type HTTPHandler

type HTTPHandler struct {
	// contains filtered or unexported fields
}

HTTPHandler is an HTTP handler for the given path and method.

func NewHTTPHandler

func NewHTTPHandler(path, method string, handle http.HandlerFunc, action string, zcapProtected bool) *HTTPHandler

NewHTTPHandler returns an instance of HTTPHandler that shouldn't be zcap protected.

func (*HTTPHandler) Action

func (h *HTTPHandler) Action() string

Action returns action associated with request path.

func (*HTTPHandler) Handle

func (h *HTTPHandler) Handle() http.HandlerFunc

Handle returns HTTP request handler func.

func (*HTTPHandler) Method

func (h *HTTPHandler) Method() string

Method returns HTTP request method type.

func (*HTTPHandler) Path

func (h *HTTPHandler) Path() string

Path returns HTTP request path.

func (*HTTPHandler) ZCAPProtect

func (h *HTTPHandler) ZCAPProtect() bool

ZCAPProtect indicates should the path be protected by zcap.

type Handler

type Handler interface {
	Path() string
	Action() string
	ZCAPProtect() bool
	Method() string
	Handle() http.HandlerFunc
}

Handler represents an HTTP handler for controller API endpoint.

type Operation

type Operation struct {
	// contains filtered or unexported fields
}

Operation represents REST API controller.

func New

func New(cmd Cmd) *Operation

New returns REST API controller.

func (*Operation) ComputeMAC

func (o *Operation) ComputeMAC(rw http.ResponseWriter, req *http.Request)

ComputeMAC swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/computemac crypto computeMACReq

Computes message authentication code (MAC) for data.

MAC provides symmetric message authentication. Computed authentication tag for given data allows the recipient to verify that data are from the expected sender and have not been modified.

Responses:

    200: computeMACResp
default: errorResp

func (*Operation) CreateDID

func (o *Operation) CreateDID(rw http.ResponseWriter, req *http.Request)

CreateDID swagger:route POST /v1/keystores/did kms createDIDReq

Creates a DID.

Responses:

    201: createDIDResp
default: errorResp

func (*Operation) CreateKey

func (o *Operation) CreateKey(rw http.ResponseWriter, req *http.Request)

CreateKey swagger:route POST /v1/keystores/{key_store_id}/keys kms createKeyReq

Creates a new key.

Responses:

    201: createKeyResp
default: errorResp

func (*Operation) CreateKeyStore

func (o *Operation) CreateKeyStore(rw http.ResponseWriter, req *http.Request)

CreateKeyStore swagger:route POST /v1/keystores kms createKeyStoreReq

Creates a new key store.

Responses:

    201: createKeyStoreResp
default: errorResp

func (*Operation) Decrypt

func (o *Operation) Decrypt(rw http.ResponseWriter, req *http.Request)

Decrypt swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/decrypt crypto decryptReq

Decrypts a ciphertext with associated authenticated data.

The decryption verifies the authenticity and integrity of the associated data, but there are no guarantees with regard to secrecy of that data.

Responses:

    200: decryptResp
default: errorResp

func (*Operation) DeriveProof

func (o *Operation) DeriveProof(rw http.ResponseWriter, req *http.Request)

DeriveProof swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/deriveproof crypto deriveProofReq

Creates a BBS+ signature proof for a list of revealed messages.

Responses:

    200: deriveProofResp
default: errorResp

func (*Operation) Easy

func (o *Operation) Easy(rw http.ResponseWriter, req *http.Request)

Easy swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/easy crypto easyReq

Seals a message.

Responses:

    200: easyResp
default: errorResp

func (*Operation) EasyOpen

func (o *Operation) EasyOpen(rw http.ResponseWriter, req *http.Request)

EasyOpen swagger:route POST /v1/keystores/{key_store_id}/easyopen crypto easyOpenReq

Unseals a message sealed with Easy.

Responses:

    200: easyOpenResp
default: errorResp

func (*Operation) Encrypt

func (o *Operation) Encrypt(rw http.ResponseWriter, req *http.Request)

Encrypt swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/encrypt crypto encryptReq

Encrypts a message with associated authenticated data.

Encryption with associated data ensures authenticity (who the sender is) and integrity (the data has not been tampered with) of that data, but not its secrecy.

Responses:

    200: encryptResp
default: errorResp

func (*Operation) ExportKey

func (o *Operation) ExportKey(rw http.ResponseWriter, req *http.Request)

ExportKey swagger:route GET /v1/keystores/{key_store_id}/keys/{key_id} kms exportKeyReq

Exports a public key.

Responses:

    200: exportKeyResp
default: errorResp

func (*Operation) GetRESTHandlers

func (o *Operation) GetRESTHandlers() []Handler

GetRESTHandlers returns list of all handlers supported by this controller.

func (*Operation) HealthCheck

func (o *Operation) HealthCheck(rw http.ResponseWriter, _ *http.Request)

HealthCheck swagger:route GET /healthcheck server healthCheckReq

Returns a health check status.

Responses:

    200: healthCheckResp
default: errorResp

func (*Operation) ImportKey

func (o *Operation) ImportKey(rw http.ResponseWriter, req *http.Request)

ImportKey swagger:route PUT /v1/keystores/{key_store_id}/keys kms importKeyReq

Imports a private key.

Responses:

    201: importKeyResp
default: errorResp

func (*Operation) RotateKey

func (o *Operation) RotateKey(rw http.ResponseWriter, req *http.Request)

RotateKey swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/rotate kms rotateKeyReq

Rotate the key.

Responses:

    200: rotateKeyResp
default: errorResp

func (*Operation) SealOpen

func (o *Operation) SealOpen(rw http.ResponseWriter, req *http.Request)

SealOpen swagger:route POST /v1/keystores/{key_store_id}/sealopen crypto sealOpenReq

Decrypts a payload encrypted with Seal.

Responses:

    200: sealOpenResp
default: errorResp

func (*Operation) Sign

func (o *Operation) Sign(rw http.ResponseWriter, req *http.Request)

Sign swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/sign crypto signReq

Signs a message.

Responses:

    200: signResp
default: errorResp

func (*Operation) SignMulti

func (o *Operation) SignMulti(rw http.ResponseWriter, req *http.Request)

SignMulti swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/signmulti crypto signMultiReq

Creates a BBS+ signature of messages.

Responses:

    200: signMultiResp
default: errorResp

func (*Operation) UnwrapKey

func (o *Operation) UnwrapKey(rw http.ResponseWriter, req *http.Request)

UnwrapKey swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/unwrap crypto unwrapKeyReq

Unwraps a wrapped key.

Responses:

    200: unwrapKeyResp
default: errorResp

func (*Operation) Verify

func (o *Operation) Verify(rw http.ResponseWriter, req *http.Request)

Verify swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/verify crypto verifyReq

Verifies a signature.

Responses:

    200: verifyResp
default: errorResp

func (*Operation) VerifyMAC

func (o *Operation) VerifyMAC(rw http.ResponseWriter, req *http.Request)

VerifyMAC swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/verifymac crypto verifyMACReq

Verifies whether MAC is a correct authentication code for data.

Responses:

    200: verifyMACResp
default: errorResp

func (*Operation) VerifyMulti

func (o *Operation) VerifyMulti(rw http.ResponseWriter, req *http.Request)

VerifyMulti swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/verifymulti crypto verifyMultiReq

Verifies a signature of messages (BBS+).

Responses:

    200: verifyMultiResp
default: errorResp

func (*Operation) VerifyProof

func (o *Operation) VerifyProof(rw http.ResponseWriter, req *http.Request)

VerifyProof swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/verifyproof crypto verifyProofReq

Verifies a BBS+ signature proof for revealed messages.

Responses:

    200: verifyProofResp
default: errorResp

func (*Operation) WrapKey

func (o *Operation) WrapKey(rw http.ResponseWriter, req *http.Request)

WrapKey swagger:route POST /v1/keystores/{key_store_id}/wrap crypto wrapKeyReq

Wraps CEK using ECDH-ES key wrapping (Anoncrypt).

Responses:

    200: wrapKeyResp
default: errorResp

func (*Operation) WrapKeyAE

func (o *Operation) WrapKeyAE(rw http.ResponseWriter, req *http.Request)

WrapKeyAE swagger:route POST /v1/keystores/{key_store_id}/keys/{key_id}/wrap crypto wrapKeyAEReq

Wraps CEK using ECDH-1PU key wrapping (Authcrypt).

Responses:

    200: wrapKeyResp
default: errorResp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL