Documentation ¶
Overview ¶
Package core encompasses the essential message passing features of PassRep.
Index ¶
- Constants
- Variables
- type EntryView
- func (this *EntryView) ReadComment() (string, error)
- func (this *EntryView) ReadExpiry() (time.Time, error)
- func (this *EntryView) ReadExtras(user string) (interface{}, error)
- func (this *EntryView) ReadGroup() (string, error)
- func (this *EntryView) ReadIcon() (string, error)
- func (this *EntryView) ReadPassword() (string, error)
- func (this *EntryView) ReadTitle() (string, error)
- func (this *EntryView) ReadUrl() (string, error)
- func (this *EntryView) ReadUserdata() (interface{}, error)
- func (this *EntryView) ReadUsername() (string, error)
- func (this *EntryView) WriteComment(comment string) error
- func (this *EntryView) WriteExpiry(expiry time.Time) error
- func (this *EntryView) WriteExtras(extras interface{}) error
- func (this *EntryView) WriteGroup(group string) error
- func (this *EntryView) WriteIcon(icon string) error
- func (this *EntryView) WritePassword(password string) error
- func (this *EntryView) WriteTitle(title string) error
- func (this *EntryView) WriteUrl(url string) error
- func (this *EntryView) WriteUserdata(userdata interface{}) error
- func (this *EntryView) WriteUsername(username string) error
- type Error
- type Keys
- type Signature
- type SigningKey
- type User
- func (this *User) Can(query string, entry *EntryView) bool
- func (this *User) Decrypt(encrypted string) ([]byte, error)
- func (this *User) DecryptShared(encrypted string, signed string, other *User) ([]byte, []byte, error)
- func (this *User) Drop()
- func (this *User) Encrypt(data []byte) (string, error)
- func (this *User) EncryptShared(data []byte, sign []byte, other *User) (string, string, error)
- func (this *User) GetCryptoSalt() ([]byte, *Error)
- func (this *User) GetSigningSalt() ([]byte, *Error)
- func (this *User) Sign(data []byte) (string, error)
- func (this *User) Verify(signed string) (bool, []byte, error)
Constants ¶
const (
// ValidPermissions is the set of allowed permissions characters.
ValidPermissions = "rwd"
)
Variables ¶
var DB gorm.DB
Functions ¶
This section is empty.
Types ¶
type EntryView ¶
type EntryView struct { // The Id is the database row identifier. Id int64 // CreatedAt is the time when the entry was created. CreatedAt time.Time // UpdatedAt is the time when the entry was last updated. UpdatedAt time.Time // The EntryId string is the unique identifier for the password entry, and ties together the individual views into the entry of each user. EntryId string // UserId is the foreign key of the owning user's database entry. UserId int64 // The Permissions field is the signed string describing the permissions that the user has for this entry. The permissions are granted // by the associated authority. Permissions string // AuthorityId is the foreign key of the user granting the permissions for this entry. AuthorityId int64 // The Group field is the encrypted name of the group to which the entry belongs. Group string // The Icon field is the encrypted image data or path to image file of the entry. Icon string // The Title field is the encrypted title of the entry. Title string // The Username field is the encrypted username stored in the entry. Username string // The Password field is the encrypted password stored in the entry. Password string // The Url field is the encrypted url stored in the entry. Url string // The Comment field is the encrypted comment stored in the entry. Comment string // The Expiry field is the encrypted expiry date of the password stored in the entry. Expiry string // The Extras field is extra encrypted JSON data associated with the entry. Extras string // The Userdata field is extra encrypted user-specific JSON data associated with the entry. Userdata string }
EntryView instances represent one user's view of a password database entry. Most fields are kept encrypted until they need to be accessed.
func (*EntryView) ReadComment ¶
ReadComment reads the comment field of the entry, provided that the user has appropriate permissions.
func (*EntryView) ReadExpiry ¶
ReadExpiry reads the expiry date field of the entry, provided that the user has appropriate permissions.
func (*EntryView) ReadExtras ¶
ReadExtras reads the extras field of the entry, provided that the user has appropriate permissions.
func (*EntryView) ReadGroup ¶
ReadGroup reads the group field of the entry, provided that the user has appropriate permissions. Read access to the group field is granted to users with any permissions, since this field is necessary in order to be able to display the entry properly.
func (*EntryView) ReadIcon ¶
ReadIcon reads the icon field of the entry, provided that the user has appropriate permissions. Read access to the icon field is granted to users with any permissions, since this field is necessary in order to be able to display the entry properly.
func (*EntryView) ReadPassword ¶
ReadPassword reads the password field of the entry, provided that the user has appropriate permissions.
func (*EntryView) ReadTitle ¶
ReadTitle reads the title field of the entry, provided that the user has appropriate permissions. Read access to the title field is granted to users with any permissions, since this field is necessary in order to be able to display the entry properly.
func (*EntryView) ReadUrl ¶
ReadUrl reads the password field of the entry, provided that the user has appropriate permissions.
func (*EntryView) ReadUserdata ¶
ReadUserdata reads the userdata field of the entry. No specific permissions are required since this field is only ever accessible by the user and is not propagated to others.
func (*EntryView) ReadUsername ¶
ReadUsername reads the username field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteComment ¶
WriteComment writes the comment field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteExpiry ¶
WriteExpiry writes the expiry field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteExtras ¶
WriteExtras writes the extras field of the entry, provided that the user has appropriate permissions and a valid encryption key.
func (*EntryView) WriteGroup ¶
WriteGroup writes the group field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteIcon ¶
WriteIcon writes the icon field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WritePassword ¶
WritePassword writes the password field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteTitle ¶
WriteTitle writes the title field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteUrl ¶
WriteUrl writes the url field of the entry, provided that the user has appropriate permissions.
func (*EntryView) WriteUserdata ¶
WriteUserdata writes the userdata field of the entry, provided that the user a valid encryption key.
func (*EntryView) WriteUsername ¶
WriteUsername writes the username field of the entry, provided that the user has appropriate permissions.
type Error ¶
type Error struct { // The File is the source file where the error originated. File string // The Line is the source line where the error originated. Line int // The User is the name of the user for whom the error was generated. User string // The Msg is the string describing the error. Msg string }
The Error type is the basic PWS error type used when no other type is more appropriate.
func NewError ¶
func NewError(content interface{}, user ...interface{}) *Error
NewError produces a new Error instance.
type Keys ¶
type Keys struct { // The CryptoKey field is the private symmetric encryption key for the user's own data. CryptoKey []byte // The SigningKey is the ECDSA private (and public) key used for signing entry and permission changes. SigningKey *ecdsa.PrivateKey }
The Keys structure holds the private cryptographic and signing keys of a user.
func MakeKeys ¶
MakeKeys takes the password salts from the user as well as the user's password, and generates the corresponding set of private keys.
func (*Keys) PublicSigningKey ¶
PublicSigningKey provides access to the user's public ECDSA key.
func (*Keys) PublicSigningKeyNoCurve ¶
func (this *Keys) PublicSigningKeyNoCurve() *SigningKey
PublicSigningKey provides access to the user's public ECDSA key.
type SigningKey ¶
The SigningKey structure represents an ECDSA key without the curve info.
type User ¶
type User struct { // The Id is the database row identifier. Id int64 // CreatedAt is the time when the user was created. CreatedAt time.Time // UpdatedAt is the time when the user was last updated. UpdatedAt time.Time // The Name is the user's username. Name string `sql:"not null;unique"` // The CryptoSalt is a base64 encoded random value used when generating the user's symmetric encryption keys. CryptoSalt string `sql:"not null;unique"` // The SigningSalt is a base64 encoded random value used when generating the user's ECDSA keys. SigningSalt string `sql:"not null;unique"` // PublicKey is the user's current public key. PublicKey string `sql:"not null;unique"` // contains filtered or unexported fields }
The User structure represents an entity capable of interacting with password entries.
func NewUser ¶
The NewUser function instantiates a new user object and adds the user to the database.
func (*User) Can ¶
Can tests whether the user has at least one of the passed in permissions on the given entry. The special value "*" may be used for the query to determine if the user has any permissions on the entry.
func (*User) Decrypt ¶
The Decrypt function decrypts a base64 encoded string that was encrypted with the user's private symmetric encryption key.
func (*User) DecryptShared ¶
func (this *User) DecryptShared(encrypted string, signed string, other *User) ([]byte, []byte, error)
The DecryptShared function base64 decodes and decrypts data using a shared secret determined between two users.
func (*User) Drop ¶
func (this *User) Drop()
Drop removes the user from the database, but does not delete the corresponding Go structure.
func (*User) Encrypt ¶
The Encrypt function encrypts and base64 encodes data with the user's private symmetric encryption key.
func (*User) EncryptShared ¶
The EncryptShared function encrypts and base64 encodes data using a shared secret determined between two users.
func (*User) GetCryptoSalt ¶
GetCryptoSalt decodes to a byte slice the base64 encoded CryptoSalt.
func (*User) GetSigningSalt ¶
GetSigningSalt decodes to a byte slice the base64 encoded SigningSalt.