Documentation ¶
Index ¶
- Constants
- Variables
- type Skykey
- func (sk *Skykey) CipherKey() (crypto.CipherKey, error)
- func (sk *Skykey) CipherType() crypto.CipherType
- func (sk *Skykey) DeriveSubkey(derivation []byte) (Skykey, error)
- func (sk *Skykey) FromString(s string) error
- func (sk *Skykey) GenerateFileSpecificSubkey() (Skykey, error)
- func (sk *Skykey) GenerateSkyfileEncryptionID() ([SkykeyIDLen]byte, error)
- func (sk Skykey) ID() (keyID SkykeyID)
- func (sk *Skykey) IsValid() error
- func (sk *Skykey) MatchesSkyfileEncryptionID(encryptionID, nonce []byte) (bool, error)
- func (sk *Skykey) Nonce() []byte
- func (sk *Skykey) SubkeyWithNonce(nonce []byte) (Skykey, error)
- func (sk Skykey) ToString() (string, error)
- type SkykeyID
- type SkykeyManager
- func (sm *SkykeyManager) AddKey(sk Skykey) error
- func (sm *SkykeyManager) CreateKey(name string, skykeyType SkykeyType) (Skykey, error)
- func (sm *SkykeyManager) IDByName(name string) (SkykeyID, error)
- func (sm *SkykeyManager) KeyByID(id SkykeyID) (Skykey, error)
- func (sm *SkykeyManager) KeyByName(name string) (Skykey, error)
- func (sm *SkykeyManager) Skykeys() []Skykey
- func (sm *SkykeyManager) SupportsSkykeyType(skykeyType SkykeyType) bool
- type SkykeyType
Constants ¶
const ( // SkykeyScheme is the URI scheme for encoded skykeys. SkykeyScheme = "skykey" // SkykeyIDLen is the length of a SkykeyID SkykeyIDLen = 16 // MaxKeyNameLen is the maximum length of a skykey's name. MaxKeyNameLen = 128 )
const ( // TypeInvalid represents an invalid skykey type. TypeInvalid = SkykeyType(0x00) // TypePublicID is a Skykey that uses XChaCha20. It reveals its // skykey ID in *every* skyfile it encrypts. TypePublicID = SkykeyType(0x01) // TypePrivateID is a Skykey that uses XChaCha20 that does not // reveal its skykey ID when encrypting Skyfiles. Instead, it marks the skykey // used for encryption by storing an encrypted identifier that can only be // successfully decrypted with the correct skykey. TypePrivateID = SkykeyType(0x02) )
Define SkykeyTypes. Constants stated explicitly (instead of `SkykeyType(iota)`) to avoid re-ordering mistakes in the future.
Variables ¶
var ( // SkykeySpecifier is used as a prefix when hashing Skykeys to compute their // ID. SkykeySpecifier = types.NewSpecifier("Skykey") // ErrInvalidSkykeyType is returned when an invalid SkykeyType is being used. ErrInvalidSkykeyType = errors.New("Invalid skykey type") )
var ( // SkykeyFileMagic is the first piece of data found in a Skykey file. SkykeyFileMagic = types.NewSpecifier("SkykeyFile") // ErrSkykeyWithNameAlreadyExists indicates that a key cannot be created or added // because a key with the same name is already being stored. ErrSkykeyWithNameAlreadyExists = errors.New("Skykey name already used by another key.") // ErrSkykeyWithIDAlreadyExists indicates that a key cannot be created or // added because a key with the same ID (and therefore same key entropy) is // already being stored. ErrSkykeyWithIDAlreadyExists = errors.New("Skykey ID already exists.") // ErrNoSkykeysWithThatID indicates that the skykey manager doesn't have a key // with that ID. ErrNoSkykeysWithThatID = errors.New("No Skykey is associated with that ID") // SkykeyPersistFilename is the name of the skykey persistence file. SkykeyPersistFilename = "skykeys.dat" )
Functions ¶
This section is empty.
Types ¶
type Skykey ¶
type Skykey struct { Name string Type SkykeyType Entropy []byte }
Skykey is a key used to encrypt/decrypt skyfiles.
func (*Skykey) CipherType ¶
func (sk *Skykey) CipherType() crypto.CipherType
CipherType returns the crypto.CipherType used by this Skykey.
func (*Skykey) DeriveSubkey ¶
DeriveSubkey is used to create Skykeys with the same key, but with a different nonce. This is used to create file-specific keys, and separate keys for Skyfile baseSector uploads and fanout uploads.
func (*Skykey) FromString ¶
FromString decodes the base64 string into a Skykey.
func (*Skykey) GenerateFileSpecificSubkey ¶
GenerateFileSpecificSubkey creates a new subkey specific to a certain file being uploaded/downloaded. Skykeys can only be used once with a given nonce, so this method is used to generate keys with new nonces when a new file is uploaded.
func (*Skykey) GenerateSkyfileEncryptionID ¶
func (sk *Skykey) GenerateSkyfileEncryptionID() ([SkykeyIDLen]byte, error)
GenerateSkyfileEncryptionID creates an encrypted identifier that is used for PrivateID encrypted files. NOTE: This method MUST only be called using a FileSpecificSkykey.
func (Skykey) ID ¶
ID returns the ID for the Skykey. A master Skykey and all file-specific skykeys derived from it share the same ID because they only differ in nonce values, not key values. This fact is used to identify the master Skykey with which a Skyfile was encrypted.
func (*Skykey) MatchesSkyfileEncryptionID ¶
MatchesSkyfileEncryptionID returns true if and only if the skykey was the one used with this nonce to create the encryptionID.
func (*Skykey) SubkeyWithNonce ¶
SubkeyWithNonce creates a new subkey with the same key data as this key, but with the given nonce.
type SkykeyID ¶
type SkykeyID [SkykeyIDLen]byte
SkykeyID is the identifier of a skykey.
func (*SkykeyID) FromString ¶
FromString decodes the base64 string into a Skykey ID.
type SkykeyManager ¶
type SkykeyManager struct {
// contains filtered or unexported fields
}
SkykeyManager manages the creation and handling of new skykeys which can be referenced by their unique name or identifier.
func NewSkykeyManager ¶
func NewSkykeyManager(persistDir string) (*SkykeyManager, error)
NewSkykeyManager creates a SkykeyManager for managing skykeys.
func (*SkykeyManager) AddKey ¶
func (sm *SkykeyManager) AddKey(sk Skykey) error
AddKey adds the given Skykey to the skykey manager.
func (*SkykeyManager) CreateKey ¶
func (sm *SkykeyManager) CreateKey(name string, skykeyType SkykeyType) (Skykey, error)
CreateKey creates a new Skykey under the given name and SkykeyType.
func (*SkykeyManager) IDByName ¶
func (sm *SkykeyManager) IDByName(name string) (SkykeyID, error)
IDByName returns the ID associated with the given key name.
func (*SkykeyManager) KeyByID ¶
func (sm *SkykeyManager) KeyByID(id SkykeyID) (Skykey, error)
KeyByID returns the Skykey associated with that ID.
func (*SkykeyManager) KeyByName ¶
func (sm *SkykeyManager) KeyByName(name string) (Skykey, error)
KeyByName returns the Skykey associated with that key name.
func (*SkykeyManager) Skykeys ¶
func (sm *SkykeyManager) Skykeys() []Skykey
Skykeys returns a slice containing each Skykey being stored.
func (*SkykeyManager) SupportsSkykeyType ¶
func (sm *SkykeyManager) SupportsSkykeyType(skykeyType SkykeyType) bool
SupportsSkykeyType returns true if and only if the SkykeyManager supports skykeys with the given type.
type SkykeyType ¶
type SkykeyType byte
SkykeyType encodes the encryption scheme and method used by the Skykey.
func (SkykeyType) CipherType ¶
func (t SkykeyType) CipherType() crypto.CipherType
CipherType returns the crypto.CipherType used by this Skykey.
func (*SkykeyType) FromString ¶
func (t *SkykeyType) FromString(s string) error
FromString reads a SkykeyType from a string.
func (SkykeyType) ToString ¶
func (t SkykeyType) ToString() string
ToString returns the string representation of the ciphertype.