Documentation
¶
Overview ¶
Package ickp implements various key type handlers and associated utility routines ickp stands for IC Key Package
Index ¶
- Constants
- Variables
- func AEADDecryptPEMBlock(b *pem.Block, password []byte) ([]byte, error)
- func AEADEncryptPEMBlock(rand io.Reader, blockType string, data, password []byte) (*pem.Block, error)
- func GenKeysECDSA(r io.Reader) (*ecdsa.PrivateKey, error)
- func GenKeysRSA(r io.Reader) (*rsa.PrivateKey, error)
- type AcCOMM
- type Ed25519PrivateKey
- type IdentityKey
- func (i *IdentityKey) FromKeyFiles(prefix string, passwd []byte) (err error)
- func (i *IdentityKey) PKIXToPriv(rd io.Reader, passwd []byte) error
- func (i *IdentityKey) PKIXToPub(rd io.Reader) (err error)
- func (i *IdentityKey) PrivToPKIX(wr io.Writer, passwd []byte) error
- func (i *IdentityKey) PubToPKIX(wr io.Writer) error
- func (i *IdentityKey) ToKeyFiles(prefix string, passwd []byte) error
- func (i *IdentityKey) Type() string
- func (i *IdentityKey) Validate() (err error)
- type IdentityPublicKey
- type KexKey
- type KeyGenerator
- type PKMap
- type PSKMap
- func (psk *PSKMap) DelPKMapEntry(server, nick string) bool
- func (psk *PSKMap) File2Map(infilestr string, passwd []byte) (bool, error)
- func (psk *PSKMap) GetPKMap(server string) (*PKMap, bool)
- func (psk *PSKMap) GetPKMapEntry(server string, nick string) (*KexKey, bool)
- func (psk *PSKMap) GetRDMap(server string) (*RDMap, bool)
- func (psk *PSKMap) GetRDMapEntry(server string, channel string) ([]byte, bool)
- func (psk *PSKMap) GetSKMap(server string) (*SKMap, bool)
- func (psk *PSKMap) GetSKMapEntry(server string, channel string) (*SecretKey, bool)
- func (psk *PSKMap) Map2File(outfilestr string, passwd []byte) (bool, error)
- func (psk *PSKMap) SetPKMapEntry(server string, nick string, pk *KexKey)
- func (psk *PSKMap) SetRDMapEntry(server, channel string, rnd []byte)
- func (psk *PSKMap) SetSKMapEntry(server string, channel string, sk *SecretKey)
- func (psk *PSKMap) String() string
- type RDMap
- type SKMap
- type SecretKey
- func (sk *SecretKey) GetBob() []byte
- func (sk *SecretKey) GetKey() []byte
- func (sk *SecretKey) GetKeyLen() int
- func (sk *SecretKey) GetNonce() uint32
- func (sk *SecretKey) GetSealKey() *[32]byte
- func (sk *SecretKey) IncNonce(n uint32)
- func (sk *SecretKey) NewKey()
- func (sk *SecretKey) RndKey(rnd []byte)
- func (sk *SecretKey) SetBob(bob []byte)
- func (sk *SecretKey) SetKey(keydata []byte)
- func (sk *SecretKey) SetNonce(nonce uint32)
- func (sk *SecretKey) String() string
Constants ¶
const ( KEYRSA = iota KEYECDSA KEYEC25519 KeyRSAStr = "ic-rsa" KeyECDSAStr = "ic-ecdsa" KeyEC25519Str = "ic-25519" PEMHDR_RSA = "RSA PRIVATE KEY" PEMHDR_ECDSA = "ECDSA PRIVATE KEY" PEMHDR_25519 = "EC25519 PRIVATE KEY" )
const (
KEYSIZE_RSA = 4096
)
Variables ¶
var ( S2K = map[string]int{ KeyRSAStr: KEYRSA, KeyECDSAStr: KEYECDSA, KeyEC25519Str: KEYEC25519, } K2S = map[int]string{ KEYRSA: KeyRSAStr, KEYECDSA: KeyECDSAStr, KEYEC25519: KeyEC25519Str, } )
var ACrun bool
var AcHomeDir string
var AcIdPrivFile string
var AcIdPubFile string
var AcSaveFile string
var LocalUser *user.User
Functions ¶
func AEADDecryptPEMBlock ¶
DecryptPEMBlock takes a password encrypted PEM block and the password used to encrypt it and returns a slice of decrypted DER encoded bytes. It inspects the DEK-Info header to determine the algorithm used for decryption. If no DEK-Info header is present, an error is returned. If an incorrect password is detected an IncorrectPasswordError is returned.
func AEADEncryptPEMBlock ¶
func AEADEncryptPEMBlock(rand io.Reader, blockType string, data, password []byte) (*pem.Block, error)
AEADEncryptPEMBlock returns a PEM block of the specified type holding the given DER-encoded data encrypted with AES-GCM256 algorithm, key is derived using PBKDF2 on the password. Header will be :
func GenKeysECDSA ¶
func GenKeysECDSA(r io.Reader) (*ecdsa.PrivateKey, error)
func GenKeysRSA ¶
func GenKeysRSA(r io.Reader) (*rsa.PrivateKey, error)
Types ¶
type AcCOMM ¶
we hash our data based on server we're connected to each entry will host channel keys and public keys within that server context
type Ed25519PrivateKey ¶
type Ed25519PrivateKey struct { Pub ed25519.PublicKey Priv ed25519.PrivateKey }
func GenKeysED25519 ¶
func GenKeysED25519(r io.Reader) (*Ed25519PrivateKey, error)
TODO: need to implement type Signer interface
which mean we need Public() and Sign()
func (*Ed25519PrivateKey) Public ¶
func (priv *Ed25519PrivateKey) Public() crypto.PublicKey
func (*Ed25519PrivateKey) Sign ¶
func (priv *Ed25519PrivateKey) Sign(r io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error)
type IdentityKey ¶
type IdentityKey struct {
// contains filtered or unexported fields
}
func LoadIdentityKey ¶
func LoadIdentityKey(prefix string, passwd []byte) (i *IdentityKey, err error)
func NewIdentityKey ¶
func NewIdentityKey(keytype int) (*IdentityKey, error)
func (*IdentityKey) FromKeyFiles ¶
func (i *IdentityKey) FromKeyFiles(prefix string, passwd []byte) (err error)
will try to load fprefix.pub / fprefix
func (*IdentityKey) PKIXToPriv ¶
func (i *IdentityKey) PKIXToPriv(rd io.Reader, passwd []byte) error
func (*IdentityKey) PrivToPKIX ¶
func (i *IdentityKey) PrivToPKIX(wr io.Writer, passwd []byte) error
func (*IdentityKey) ToKeyFiles ¶
func (i *IdentityKey) ToKeyFiles(prefix string, passwd []byte) error
func (*IdentityKey) Type ¶
func (i *IdentityKey) Type() string
func (*IdentityKey) Validate ¶
func (i *IdentityKey) Validate() (err error)
just validation that the key is valid and complete..
type IdentityPublicKey ¶
type KexKey ¶
type KexKey struct { Nickname string Userhost string Server string Pubkey string HasPriv bool // Pubfp string // 32 bytes hex encoded string of the hash... XXX we will see if it's problematic later.. Timestamp int64 PubFP [32]byte // 32 bytes hash of the public key... CreaTime time.Time // contains filtered or unexported fields }
KexKey describe the internal structure stored in memory for public/private key pairs owned or received from peers
func CreateKxKeys ¶
CreateKxKeys create an KexKey structure using provide randomness source and compute the initial EC Ephemeral keypair XXX Make sure PRNG is strong.. may be use fortuna...
func CreateKxKeys2 ¶
XXX TODO: to reimplement properly..
func (*KexKey) GetPrivkey ¶
GetPrivkey retrieve and return the private key (privkey) of the current AcMyKeys structure.
func (*KexKey) GetPubfp ¶
GetPubfp retrieve and return the public key fingerprint associated with the current key.
func (*KexKey) GetPubkey ¶
GetPubkey retrieve and return the public key component from the current KexKey structure.
type KeyGenerator ¶
type KeyGenerator struct {
// contains filtered or unexported fields
}
type PSKMap ¶
this type is a map[string](*AcCOMM) it's a map defining a set of Public/Session Keys used for encrypting and KEX on a specific network based on the server name as hash key. its not perfect but it avoid basic one-client-multiple-network-same-nick-same-channels scenarios. is it too complicated? hmm we need to make it clear
var ACmap *PSKMap
some variable to handle the maps and the run loop
func (*PSKMap) DelPKMapEntry ¶
func (*PSKMap) GetPKMapEntry ¶
PKMaps
func (*PSKMap) GetRDMapEntry ¶
RDMaps
func (*PSKMap) GetSKMapEntry ¶
SKMaps
func (*PSKMap) SetPKMapEntry ¶
XXX not our job to do initial root data struct allocation... let's try..
func (*PSKMap) SetRDMapEntry ¶
func (*PSKMap) SetSKMapEntry ¶
type RDMap ¶
RDMap store the random value we use for "protecting/obfuscating" secret keys in memory, it is far from perfect, but better than pure plain text.