Documentation ¶
Index ¶
- func Date() string
- func Digest(hash crypto.Hash, message []byte) string
- func GenerateKey(bits int) (privateKey *rsa.PrivateKey, privateKeyBytes []byte, publicKeyBytes []byte)
- func ParseSignature(signatureStr string) map[string]string
- func PrivateKeyFromBytes(privateKeyBytes []byte) (*rsa.PrivateKey, error)
- type GenerateInput
- type GenerateOutput
- type Signature
- type Verifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Digest ¶
Example: signature_header.Digest(crypto.SHA256, []byte(`{"@context": [...], ...}`))
Output: SHA-256=7Uq...Q==
func GenerateKey ¶
func GenerateKey(bits int) (privateKey *rsa.PrivateKey, privateKeyBytes []byte, publicKeyBytes []byte)
func ParseSignature ¶ added in v0.1.1
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(privateKeyBytes []byte) (*rsa.PrivateKey, error)
Types ¶
type GenerateInput ¶ added in v0.2.0
type GenerateInput struct { PrivateKeyBytes []byte Algorithm crypto.Hash Host string Path string Body []byte KeyID string }
Example:
signature_header.GenerateInput{ PrivateKeyBytes: []byte("-----BEGIN RSA PRIVATE KEY-----..."), Algorithm: crypto.SHA256, Host: "example.com", Path: "/inbox", KeyID: "https://snippet.social/@juunini#main-key", }
type GenerateOutput ¶ added in v0.2.0
func Generate ¶ added in v0.2.0
func Generate(input GenerateInput) (*GenerateOutput, error)
Example:
headers, err := signature_header.Generate(signature_header.GenerateInput{ PrivateKeyBytes: []byte("-----BEGIN RSA PRIVATE KEY-----..."), Algorithm: crypto.SHA256, Host: "example.com", Path: "/inbox", KeyID: "https://snippet.social/@juunini#main-key", })
type Signature ¶
type Signature struct { PrivateKey *rsa.PrivateKey Algorithm crypto.Hash Date string Digest string Host string Path string KeyID string }
Example:
privateKey, err := signature_header.PrivateKeyFromBytes(privateKeyBytes) date := signature_header.Date() digest := signature_header.Digest(crypto.SHA256, message) signature, err := signature_header.Signature{ PrivateKey: privateKey, Algorithm: crypto.SHA256, Date: date, Digest: digest, Host: "yodangang.express", Path: "/users/9iffvxhojp/inbox", KeyID: "https://snippet.cloudmt.co.kr/@juunini#main-key", }.String()
type Verifier ¶ added in v0.1.0
type Verifier struct { Method string URL string Headers map[string]string // contains filtered or unexported fields }
func (*Verifier) VerifyWithActor ¶ added in v0.1.0
func (*Verifier) VerifyWithBody ¶ added in v0.1.0
func (*Verifier) VerifyWithPublicKey ¶ added in v0.1.0
func (*Verifier) VerifyWithPublicKeyStr ¶ added in v0.1.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.