Documentation
¶
Index ¶
- Constants
- Variables
- func Base32Decode(b32 string) (binary []byte, err error)
- func Base32Encode(binary []byte) string
- func CalcDescIDByOnion(onion string, t time.Time, replica int) (string, error)
- func CalcDescriptorID(permID, secretID []byte) (descID []byte)
- func CalcPermanentID(pk *rsa.PublicKey) (permId []byte, err error)
- func CalcSecretID(permID []byte, now time.Time, replica byte) (secretID []byte)
- func GenerateOnionKey(rand io.Reader, version string) (crypto.PrivateKey, error)
- func GenerateOnionKeyV2(rand io.Reader) (crypto.PrivateKey, error)
- func GenerateOnionKeyV3(rand io.Reader) (crypto.PrivateKey, error)
- func Hash(data []byte) (hash []byte)
- func InetPortFromByteString(str []byte) (port uint16, err error)
- func LoadPrivateKeyFile(filename string) (crypto.PrivateKey, crypto.PublicKey, error)
- func OnionAddress(pk crypto.PublicKey) (string, error)
- func OnionAddressChecksumV3(pk []byte) []byte
- func OnionAddressIsValid(onionAddress string) bool
- func OnionAddressIsValidV2(onionAddress string) bool
- func OnionAddressIsValidV3(onionAddress string) bool
- func OnionAddressPublicKeyV3(onionAddress string) (ed25519.PublicKey, error)
- func OnionAddressV2(pk *rsa.PublicKey) (onionAddress string, err error)
- func OnionAddressV3(pk ed25519.PublicKey) (onionAddress string, err error)
- func RSAPubkeyHash(pk *rsa.PublicKey) (derHash []byte, err error)
- type Bandwidth
- type Certificate
- type Curve25519Pubkey
- type Descriptor
- type Ed25519Pubkey
- type Ed25519Signature
- type Exit6Policy
- type ExitPolicy
- type ExtType
- type Extension
- type IntroductionPoint
- type OnionDescriptor
- func (desc *OnionDescriptor) Bytes() []byte
- func (desc *OnionDescriptor) Finalize(now time.Time) error
- func (desc *OnionDescriptor) FullSign(signer crypto.Signer) error
- func (desc *OnionDescriptor) InitDefaults()
- func (desc *OnionDescriptor) OnionID() (string, error)
- func (desc *OnionDescriptor) Sign(signer crypto.Signer) error
- func (desc *OnionDescriptor) VerifySignature() error
- type Platform
- type RSASignature
Constants ¶
const ( PublicationTimeFormat = "2006-01-02 15:04:05" NTorOnionKeySize = 32 )
const Curve25519PubkeySize = 32
const Ed25519PubkeySize = 32
const Ed25519SignatureSize = 64
const HashType = crypto.SHA1
const RSAPubkeySize = 128
const RSASignatureSize = 128
Variables ¶
var ( OnionAddressChecksumLengthV3 = 2 OnionAddressVersionFieldV3 = []byte{0x03} OnionAddressVersionFieldLengthV3 = 1 OnionAddressLengthV3 = ed25519.PublicKeySize + OnionAddressVersionFieldLengthV3 + OnionAddressChecksumLengthV3 OnionChecksumPrefix = []byte(".onion checksum") )
v3 onion addresses
var ( MinReplica = 0 MaxReplica = 1 DescVersion = 2 ProtocolVersions = []int{2, 3} )
var (
OnionAddressLengthV2 = 10
)
v2 onion addresses
Functions ¶
func Base32Decode ¶
func Base32Encode ¶
XXX: here might be an error for new ed25519 addresses (! mod 5bits=0)
func CalcDescIDByOnion ¶
func CalcDescriptorID ¶
func CalcPermanentID ¶
Calculate permanent ID from RSA public key
func CalcSecretID ¶
TODO: there is no `descriptor-cookie` now (because we need IP list encryption etc)
func GenerateOnionKey ¶
Generate private key for onion service using rand as the entropy source. Recognized versions are "2", "3", "current", "best".
func GenerateOnionKeyV2 ¶
func GenerateOnionKeyV2(rand io.Reader) (crypto.PrivateKey, error)
Generate v2 onion service key (RSA-1024) using rand as the entropy source.
func GenerateOnionKeyV3 ¶
func GenerateOnionKeyV3(rand io.Reader) (crypto.PrivateKey, error)
Generate v3 onion address key (Ed25519) using rand as the entropy source
func InetPortFromByteString ¶
func LoadPrivateKeyFile ¶
func OnionAddress ¶
OnionAddress returns onion address corresponding to public/private key pk.
func OnionAddressChecksumV3 ¶
Calculate onion address checksum (v3) from byte-encoded Ed25519 key
func OnionAddressIsValid ¶
Check whether onion address is a valid one.
func OnionAddressIsValidV2 ¶
Check whether onion address is a valid v2 one.
func OnionAddressIsValidV3 ¶
Check whether onion address is a valid v3 one.
func OnionAddressPublicKeyV3 ¶
Extract Ed25519 public key from the onion address.
func OnionAddressV2 ¶
OnionAddress returns the Tor Onion Service address corresponding to a given rsa.PublicKey.
func OnionAddressV3 ¶
Calculate onion address v3 from public key pk.
Types ¶
type Bandwidth ¶
func ParseBandwidthEntry ¶
type Certificate ¶
type Certificate struct { Version uint8 CertType byte ExpirationDate time.Time CertKeyType byte CertifiedKey Ed25519Pubkey NExtensions uint8 Extensions map[ExtType]Extension Signature Ed25519Signature PubkeySign bool }
func ParseCertFromBytes ¶
func ParseCertFromBytes(binCert []byte) (cert Certificate, err error)
type Curve25519Pubkey ¶
type Curve25519Pubkey [Curve25519PubkeySize]byte
type Descriptor ¶
type Descriptor struct { Nickname string InternetAddress net.IP ORPort uint16 SOCKSPort uint16 DirPort uint16 ORAddrs []net.TCPAddr IdentityEd25519 *Certificate MasterKeyEd25519 Ed25519Pubkey Bandwidth Bandwidth Platform Platform Published time.Time Fingerprint string Hibernating bool Uptime time.Duration ExtraInfoDigest string OnionKey *rsa.PublicKey OnionKeyCrosscert []byte SigningKey *rsa.PublicKey HSDirVersions []uint8 Contact string NTorOnionKey Curve25519Pubkey NTorOnionKeyCrossCert *Certificate ExitPolicy ExitPolicy Exit6Policy *Exit6Policy CachesExtraInfo bool AllowSingleHopExits bool RouterSigEd25519 Ed25519Signature RouterSignature RSASignature }
func ParseServerDescriptors ¶
func ParseServerDescriptors(descs_str []byte) (descs []Descriptor, rest string)
TODO return a pointer to descs not descs themselves?
type Ed25519Pubkey ¶
type Ed25519Pubkey [Ed25519PubkeySize]byte
type Ed25519Signature ¶
type Ed25519Signature [Ed25519SignatureSize]byte
type Exit6Policy ¶
type ExitPolicy ¶
type IntroductionPoint ¶
type IntroductionPoint struct { Identity []byte InternetAddress net.IP OnionPort uint16 OnionKey *rsa.PublicKey ServiceKey *rsa.PublicKey }
func ParseIntroPoints ¶
func ParseIntroPoints(ips_str []byte) (ips []IntroductionPoint, rest string)
func (IntroductionPoint) Bytes ¶
func (ip IntroductionPoint) Bytes() (encodedIP []byte)
XXX: replace Falalf's with graceful errors
func (*IntroductionPoint) String ¶
func (ip *IntroductionPoint) String() string
type OnionDescriptor ¶
type OnionDescriptor struct { DescID []byte Version int PermanentKey *rsa.PublicKey SecretIDPart []byte PublicationTime time.Time ProtocolVersions []int IntropointsBlock []byte Signature []byte Replica int }
func ParseOnionDescriptors ¶
func ParseOnionDescriptors(descsData []byte) (descs []OnionDescriptor, rest []byte)
TODO return a pointer to descs not descs themselves?
func (*OnionDescriptor) Bytes ¶
func (desc *OnionDescriptor) Bytes() []byte
func (*OnionDescriptor) Finalize ¶
func (desc *OnionDescriptor) Finalize(now time.Time) error
Finalize descriptor to sign.
func (*OnionDescriptor) FullSign ¶
func (desc *OnionDescriptor) FullSign(signer crypto.Signer) error
func (*OnionDescriptor) InitDefaults ¶
func (desc *OnionDescriptor) InitDefaults()
Initialize defaults
func (*OnionDescriptor) OnionID ¶
func (desc *OnionDescriptor) OnionID() (string, error)
func (*OnionDescriptor) VerifySignature ¶
func (desc *OnionDescriptor) VerifySignature() error
type RSASignature ¶
type RSASignature [RSASignatureSize]byte