Documentation ¶
Overview ¶
Package crypto contains common cryptographic elements.
Index ¶
- Constants
- Variables
- func Features(h ...Hash) info.FeatureIter
- type Hash
- func (h Hash) Available() bool
- func (h Hash) HashFunc() crypto.Hash
- func (h Hash) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (h Hash) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (h Hash) Namespace() (string, error)
- func (h Hash) New() hash.Hash
- func (h Hash) Size() int
- func (h Hash) String() string
- func (h Hash) TokenReader() xml.TokenReader
- func (h *Hash) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (h *Hash) UnmarshalXMLAttr(attr xml.Attr) error
- func (h Hash) WriteXML(w xmlstream.TokenWriter) (int, error)
- type HashOutput
Constants ¶
const ( SHA1 = Hash(crypto.SHA1) // import crypto/sha1 SHA224 = Hash(crypto.SHA224) // import crypto/sha256 SHA256 = Hash(crypto.SHA256) // import crypto/sha256 SHA384 = Hash(crypto.SHA384) // import crypto/sha512 SHA512 = Hash(crypto.SHA512) // import crypto/sha512 SHA3_256 = Hash(crypto.SHA3_256) // import golang.org/x/crypto/sha3 SHA3_512 = Hash(crypto.SHA3_512) // import golang.org/x/crypto/sha3 BLAKE2b_256 = Hash(crypto.BLAKE2b_256) // import golang.org/x/crypto/blake2b BLAKE2b_512 = Hash(crypto.BLAKE2b_512) // import golang.org/x/crypto/blake2b )
A list of commonly supported hashes and the imports required to enable them.
const NS = "urn:xmpp:hashes:2"
NS is the namespace used by this package.
Variables ¶
var ( ErrMissingAlgo = errors.New("crypto: no algo attr found") ErrUnknownAlgo = errors.New("crypto: unknown hash value") ErrUnlinkedAlgo = errors.New("crypto: attempted to use a hash function without an implementation linked in") )
A list of errors returned by functions in this package. Error checking against these errors should always use errors.Is and not a direct comparison.
var (
Feature = info.Feature{Var: NS}
)
A list of service discovery features that are supported by this package.
Functions ¶
func Features ¶
func Features(h ...Hash) info.FeatureIter
Features returns an iter that can be registered against a mux to advertise support for the hash list. The iter will return an error for any hashes that are not available in the binary.
Types ¶
type Hash ¶
Hash identifies a cryptographic hash function that is implemented in another package. It is like crypto/hash from the standard library, except only hash functions commonly supported in XMPP are given names and values have methods that are useful for communicating information about supported hashes over the wire.
func (Hash) Available ¶
Available reports whether the given hash function is linked into the binary.
func (Hash) MarshalXML ¶
MarshalXML implements xml.Marshaler. MarshalXML panics if the hash is invalid.
func (Hash) MarshalXMLAttr ¶
MarshalXMLAttr implements xml.MarshalerAttr.
func (Hash) Namespace ¶
Namespace returns a unique URN for the hash algorithm. If the hash algorithm is unknown, Namespace returns an error.
func (Hash) New ¶
New returns a new hash.Hash calculating the given hash function. New panics if the hash is invalid.
func (Hash) Size ¶
Size returns the length, in bytes, of a digest resulting from the given hash function. It doesn't require that the hash function in question be linked into the program.
func (Hash) String ¶
String implements fmt.Stringer by returning the name of the hash as it would appear in wire format. This is different from the value returned by the String method of crypto.Hash.
func (Hash) TokenReader ¶
func (h Hash) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler. TokenReader panics if the hash is invalid.
func (*Hash) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler.
func (*Hash) UnmarshalXMLAttr ¶
UnmarshalXMLAttr implements xml.UnmarshalerAttr.
type HashOutput ¶
HashOutput is used to marshal or unmarshal the results of a hash calculation.
func (HashOutput) MarshalXML ¶
func (h HashOutput) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implements xml.Marshaler.
func (HashOutput) TokenReader ¶
func (h HashOutput) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler. TokenReader panics if the original hash is invalid.
func (*HashOutput) UnmarshalXML ¶
func (h *HashOutput) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML implements xml.Unmarshaler.
func (HashOutput) WriteXML ¶
func (h HashOutput) WriteXML(w xmlstream.TokenWriter) (int, error)
WriteXML implements xmlstream.WriterTo.