Documentation
¶
Overview ¶
Package nsm implements the Nitro Security Module interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ Open: func() (FileDescriptor, error) { return os.Open("/dev/nsm") }, Syscall: syscall.Syscall, }
DefaultOptions can be used to open the default NSM session on `/dev/nsm`.
var ( // ErrSessionClosed is returned when the session is in a closed state. ErrSessionClosed error = errors.New("Session is closed") )
Functions ¶
This section is empty.
Types ¶
type ErrorGetRandomFailed ¶
ErrorGetRandomFailed is an error returned when the GetRandom request as part of a `Read` has failed with an error code, is invalid or did not return any random bytes.
func (*ErrorGetRandomFailed) Error ¶
func (err *ErrorGetRandomFailed) Error() string
Error returns the formatted string.
type ErrorIoctlFailed ¶
ErrorIoctlFailed is an error returned when the underlying ioctl syscall has failed.
func (*ErrorIoctlFailed) Error ¶
func (err *ErrorIoctlFailed) Error() string
Error returns the formatted string.
type FileDescriptor ¶
type FileDescriptor interface { // Provide the uintptr for the file descriptor. Fd() uintptr // Close the file descriptor. Close() error }
FileDescriptor is a generic file descriptor interface that can be closed. os.File conforms to this interface.
type Options ¶
type Options struct { // A function that opens the NSM device file `/dev/nsm`. Open func() (FileDescriptor, error) // A function that implements the syscall.Syscall interface and is able to // work with the file descriptor returned from `Open` as the `a1` argument. Syscall func(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) }
Options for the opening of the NSM session.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A Session is used to interact with the NSM.
func OpenDefaultSession ¶
OpenDefaultSession opens a new session with the default options.
func OpenSession ¶
OpenSession opens a new session with the provided options.
func (*Session) Close ¶
Close this session. It is not thread safe to Close while other threads are Read-ing or Send-ing.
func (*Session) Read ¶
Read entropy from the NSM device. It is safe to call this from multiple threads that are Read-ing or Send-ing, but not Close-ing. This method will always attempt to fill the whole slice with entropy thus blocking until that occurs. If reading fails, it is probably an irrecoverable error. Each Send and Read call reserves at most 16KB of memory, so having multiple parallel sends or reads might lead to increased memory usage.
func (*Session) Send ¶
Send an NSM request to the device and await its response. It safe to call this from multiple threads that are Read-ing or Send-ing, but not Close-ing. Each Send and Read call reserves at most 16KB of memory, so having multiple parallel sends or reads might lead to increased memory usage.
Directories
¶
Path | Synopsis |
---|---|
example
|
|
Package ioc generates the proper ioctl command numbers.
|
Package ioc generates the proper ioctl command numbers. |
Package request contains constructs commonly used in the NSM request payload.
|
Package request contains constructs commonly used in the NSM request payload. |
Package response contains commonly used constructs for NSM responses.
|
Package response contains commonly used constructs for NSM responses. |