ni

package module
v0.0.0-...-6f01ba1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package ni implements RFC6920: https://tools.ietf.org/html/rfc6920

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidScheme     = errors.New("invalid scheme")
	ErrInvalidDigestLen  = errors.New("invalid digest len")
	ErrSuiteNotSupported = errors.New("suite not supported")
	ErrCheckDigit        = errors.New("wrong check digit")
)

Functions

This section is empty.

Types

type URL

type URL struct {
	Authority string
	Alg       string
	Val       string
	// contains filtered or unexported fields
}

URL represents a ni-url in memory. For the specification of the properties, see RFC6920: https://tools.ietf.org/html/rfc6920

func DigestToNI

func DigestToNI(digest []byte, suite, authority string) (*URL, error)

DigestToNI constructs a URL from a digest and the corresponding suite. Authority may be an empty string, as defined in RFC6920. The suite string must conform the the table here: https://www.iana.org/assignments/named-information/named-information.xhtml

func ParseNI

func ParseNI(rawurl string) (*URL, error)

ParseNI parses a string containing an ni url, e.g. "ni:///sha-256;UyaQV-Ev4rdLoHyJJWCi11OHfrYv9E1aGQAlMO2X_-Q" into a URL struct.

func ParseNIH

func ParseNIH(raw string) (*URL, error)

ParseNIH parses a speakable representation of URL as specified in RFC6920, Section 7. If a check digit is included, it is verified. Authority is always an empty string in the returned URL, since nih strings do not carry authority information.

func (*URL) Bytes

func (u *URL) Bytes() []byte

Bytes returns the binary representation of an ni-url as specified in RFC6920, Section 6. This representation includes the suide ID in the first byte which MUST be excluded when used in cryptographic operations.

func (*URL) HexString

func (u *URL) HexString() string

HexString returns the binary representation of an ni-url as specified in RFC6920, Section 6. In contrast to ToBytes, this function returns a hex string instead. This representation includes the suide ID in the first byte which MUST be excluded when used in cryptographic operations.

func (*URL) NIH

func (u *URL) NIH() string

NIH generates a human speakable representation of URL as specified in RFC6920, Section 7. A check digit is included, the Val is divided in groups of 6.

func (*URL) String

func (u *URL) String() string

func (*URL) WellKnownURI

func (u *URL) WellKnownURI() string

WellKnownURI generates a well-known http url. The mapping is specified in RCF6920, Section 4.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL