Documentation
¶
Overview ¶
Package alg provides access to Linux AF_ALG sockets for communication with the Linux kernel crypto API.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
A Config contains optional parameters for a Conn.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
A Conn is a connection to the Linux kernel crypto API, using an AF_ALG socket. A Conn can be used to initialize Hashes via its Hash method, using the parameters configured in Dial.
Example (HashSHA1) ¶
package main import ( "encoding/hex" "fmt" "io" "log" "github.com/mdlayher/alg" ) func main() { // Dial the kernel using AF_ALG sockets. The socket must be closed when it // is no longer needed. c, err := alg.Dial(alg.SHA1()) if err != nil { log.Fatalf("failed to dial kernel: %v", err) } defer c.Close() // Retrieve a hash handle from the kernel. This can be used the same as any // other hash.Hash, but must also be closed when it is no longer needed. h, err := c.Hash() if err != nil { log.Fatalf("failed to create hash: %v", err) } defer h.Close() if _, err := io.WriteString(h, "hello, world"); err != nil { log.Fatalf("failed to hash string: %v", err) } fmt.Println(hex.EncodeToString(h.Sum(nil))) }
Output:
func Dial ¶
Dial dials a connection the Linux kernel crypto API, using the specified transformation type, algorithm name, and optional configuration. If config is nil, a default configuration will be used.
At this time, the following transformation types and algorithm types are supported:
- hash
- md5
- sha1
- sha256
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
algsha1sum
Command algsha1sum is a Go implementation of sha1sum that uses package alg to perform the SHA1 hashing operation.
|
Command algsha1sum is a Go implementation of sha1sum that uses package alg to perform the SHA1 hashing operation. |
Click to show internal directories.
Click to hide internal directories.