Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveKey ¶
func SaveKey(key PrivateKey, path string) error
SaveKey will attempt to save the specified private key to the specified file. If path is not specified, then it will use the default .dslink.key. This function will return an error on failure.
Types ¶
type ECDH ¶
type ECDH interface { // GenerateKey will create a new Private/Public key pair based on random numbers from io.Reader. // Returns error if it was unable to create keys. GenerateKey(io.Reader) (PrivateKey, error) // Marshal converts a Private/Public key pair into a Base64.RawUrlEncoded string. // Returned string separates the pairs with a space, where private key is first. // Returns an error if unable to convert values to a string. Marshal(PrivateKey) (string, error) // Unmarshal will decode a Base64.RawUrlEncoded string into a Private/Public key pair. // String may be Private / Public keys separated by a space or alternatively a private // key and the public will be generated automatically. // Returns an error if string cannot be decoded. Unmarshal(string) (PrivateKey, error) // UnmarshalPublic will decode a Base64.RawUrlEncoded string into a Public key. // Returns an error if string cannot be decoded. UnmarshalPublic(string) (PublicKey, error) // public key of the other. Returns a byte slice. GenerateSharedSecret(PrivateKey, PublicKey) []byte // HashSalt adds the provided string salt to the SharedSecret byte slice sec. // It returns a Base64 RawUrl encoded string of the SHA256 Sum of bytes. HashSalt(string, []byte) string // HashToken generates the token hash for the connection handshake. // Returns a base64 encoded SHA256 checksum of the DSId and Token. HashToken(dsId string, token string) string }
ECDH manages creating and providing keys.
type PrivateKey ¶
func LoadKey ¶
func LoadKey(path string) (PrivateKey, error)
LoadKey will try to load the public and private key configuration from disk. If no filename is specified, it will default to .dslink.key. This function returns a PrivateKey or error.
type PublicKey ¶
func (PublicKey) Base64 ¶
Base64 returns a Base64 Raw Url Encoded (no padding) string of the bytes for the public key.
func (PublicKey) DsId ¶
DsId generates the dsId for this Public Key based on the prefix supplied. DsId returned should be the prefix
func (PublicKey) Hash64 ¶
Hash64 returns the SHA256 check sum of the bytes for the public key encoded as Base64 Raw Url encoded (no padding) string.
func (PublicKey) VerifyDsId ¶
VerifyDsId confirms that the provided dsid matches the expected Hash64 for this public key.