signer

package
v0.0.0-...-8ec4c66 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 23 Imported by: 2

README

GO SDK Demo

How to download the SDK

Click this link to download the latest version.

Documentation

Index

Constants

View Source
const (
	DerivedDateFormat = "20060102"
	AlgorithmV11      = "V11-HMAC-SHA256"
)
View Source
const (
	HmacSHA256      = "HmacSHA256"
	HmacSM3         = "HmacSM3"
	EcdsaP256SHA256 = "EcdsaP256SHA256"
	SM2SM3          = "SM2SM3"

	BasicDateFormat     = "20060102T150405Z"
	HeaderXDate         = "X-Sdk-Date"
	HeaderHost          = "host"
	HeaderAuthorization = "Authorization"
)
View Source
const (
	DateFormat           = "20060102T150405Z"
	SignAlgorithm        = "SDK-HMAC-SHA256"
	HeaderXDateTime      = "X-Sdk-Date"
	HeaderXHost          = "host"
	HeaderXAuthorization = "Authorization"
	HeaderXContentSha256 = "X-Sdk-Content-Sha256"
)

Variables

This section is empty.

Functions

func AuthHeaderValue

func AuthHeaderValue(signatureStr, accessKeyStr string, signedHeaders []string) string

Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign

func CanonicalHeaders

func CanonicalHeaders(request *http.Request, signerHeaders []string) string

CanonicalHeaders

func CanonicalQueryString

func CanonicalQueryString(request *http.Request) string

CanonicalQueryString

func CanonicalRequest

func CanonicalRequest(request *http.Request, signedHeaders []string) (string, error)

Build a CanonicalRequest from a regular request string

func CanonicalURI

func CanonicalURI(request *http.Request) string

CanonicalURI returns request uri

func HexEncodeSHA256Hash

func HexEncodeSHA256Hash(body []byte) (string, error)

HexEncodeSHA256Hash returns hexcode of sha256

func RequestPayload

func RequestPayload(request *http.Request) ([]byte, error)

RequestPayload

func SignStringToSign

func SignStringToSign(stringToSign string, signingKey []byte) (string, error)

Create the HWS Signature.

func SignedHeaders

func SignedHeaders(r *http.Request) []string

SignedHeaders

func StringToSign

func StringToSign(canonicalRequest string, t time.Time) (string, error)

Create a "String to Sign".

Types

type DerivedSigner

type DerivedSigner struct {
	Key                    string
	Secret                 string
	DerivedAuthServiceName string
	RegionID               string
}

Derived algorithm structure, all fields are required

func GetDerivedSigner

func GetDerivedSigner() DerivedSigner

func (DerivedSigner) Sign

func (s DerivedSigner) Sign(request *http.Request) error

Sign Use derivative algorithms to authenticate AK/SK

type IAKSKSigner

type IAKSKSigner interface {
	Sign(req *http.Request, ak, sk string) (map[string]string, error)
}

func GetSigner

func GetSigner(alg SigningAlgorithm) (IAKSKSigner, error)

type ISigningKey

type ISigningKey interface {
	Sign(data []byte) ([]byte, error)
	Verify(signature, data []byte) bool
}

type P256SHA256Signer

type P256SHA256Signer struct {
}

func (P256SHA256Signer) GetSigningKey

func (s P256SHA256Signer) GetSigningKey(ak, sk string) (ISigningKey, error)

GetSigningKey get the derived key based on ak and sk.

func (P256SHA256Signer) Sign

func (s P256SHA256Signer) Sign(req *http.Request, ak, sk string) (map[string]string, error)

type P256SigningKey

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

func (P256SigningKey) Sign

func (k P256SigningKey) Sign(data []byte) ([]byte, error)

func (P256SigningKey) Verify

func (k P256SigningKey) Verify(signature, data []byte) bool

type SM2SM3Signer

type SM2SM3Signer struct {
}

func (SM2SM3Signer) GetSigningKey

func (s SM2SM3Signer) GetSigningKey(ak, sk string) (ISigningKey, error)

func (SM2SM3Signer) Sign

func (s SM2SM3Signer) Sign(req *http.Request, ak, sk string) (map[string]string, error)

type SM2SigningKey

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

func (SM2SigningKey) Sign

func (k SM2SigningKey) Sign(data []byte) ([]byte, error)

func (SM2SigningKey) Verify

func (k SM2SigningKey) Verify(signature, data []byte) bool

type SM3Signer

type SM3Signer struct {
}

func (SM3Signer) Sign

func (s SM3Signer) Sign(req *http.Request, ak, sk string) (map[string]string, error)

type Signer

type Signer struct {
	Key    string
	Secret string
}

Signature HWS meta

func (*Signer) Sign

func (s *Signer) Sign(request *http.Request) error

SignRequest set Authorization header

type SigningAlgorithm

type SigningAlgorithm string

Jump to

Keyboard shortcuts

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