Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeTicket ¶
func MakeTicket(data *KnotFreePayload, privateKey []byte) ([]byte, error)
MakeTicket is
func ParseOpenSSHPrivateKey ¶
ParseOpenSSHPrivateKey parses openssh private key in the file here.
func ParseOpenSSHPublicKey ¶
ParseOpenSSHPublicKey an ed25519 result is 32 bytes
Types ¶
type KnotFreePayload ¶
type KnotFreePayload struct { //jwt.Payload ExpirationTime uint32 `json:"exp"` Issuer string `json:"iss"` JWTID string `json:"jti"` Input float32 `json:"in"` // bytes per hour Output float32 `json:"out"` // bytes per hour Subscriptions float32 `json:"su"` // per hour Connections float32 `json:"co"` // per hour URL string `json:"url"` // address of the service eg. "knotfreeiot.io" }
KnotFreePayload is
func VerifyTicket ¶
func VerifyTicket(ticket []byte, publicKey []byte) (*KnotFreePayload, bool)
VerifyTicket is
type ZeroReader ¶
type ZeroReader struct{}
ZeroReader is too public
Example ¶
package main import ( "crypto/ed25519" "encoding/base64" "fmt" "github.com/awootton/knotfreeiot/tickets" ) func main() { var zero tickets.ZeroReader public, private, _ := ed25519.GenerateKey(zero) fmt.Println(base64.StdEncoding.WithPadding(base64.NoPadding).EncodeToString(public)) fmt.Println(base64.StdEncoding.WithPadding(base64.NoPadding).EncodeToString(private)) message := []byte("test message") sig := ed25519.Sign(private, message) if !ed25519.Verify(public, message, sig) { fmt.Println("valid signature rejected") } else { fmt.Println("good") } // Expected: O2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2ik // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7aie8zrakLWKjqNAqbw1zZTIVdx3iQ6Y6wEihi1naKQ // good }
Output:
Click to show internal directories.
Click to hide internal directories.