key: Remove unused convenience methods

This commit is contained in:
Alexander Neumann 2015-05-03 18:07:21 +02:00
parent 1213d87b1a
commit 7af918cfdd
2 changed files with 2 additions and 43 deletions

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"os" "os"
"os/user" "os/user"
"time" "time"
@ -212,46 +211,6 @@ func AddKey(s *Server, password string, template *crypto.Key) (*Key, error) {
return newkey, nil return newkey, nil
} }
// Encrypt encrypts and authenticates data with the master key. Stored in
// ciphertext is IV || Ciphertext || MAC. Returns the ciphertext, which is
// extended if necessary.
func (k *Key) Encrypt(ciphertext, plaintext []byte) ([]byte, error) {
return crypto.Encrypt(k.master, ciphertext, plaintext)
}
// EncryptTo encrypts and authenticates data with the master key. The returned
// io.Writer writes IV || Ciphertext || MAC.
func (k *Key) EncryptTo(wr io.Writer) io.WriteCloser {
return crypto.EncryptTo(k.master, wr)
}
// Decrypt verifes and decrypts the ciphertext with the master key. Ciphertext
// must be in the form IV || Ciphertext || MAC.
func (k *Key) Decrypt(plaintext, ciphertext []byte) ([]byte, error) {
return crypto.Decrypt(k.master, plaintext, ciphertext)
}
// DecryptFrom verifies and decrypts the ciphertext read from rd and makes it
// available on the returned Reader. Ciphertext must be in the form IV ||
// Ciphertext || MAC. In order to correctly verify the ciphertext, rd is
// drained, locally buffered and made available on the returned Reader
// afterwards. If a MAC verification failure is observed, it is returned
// immediately.
func (k *Key) DecryptFrom(rd io.Reader) (io.ReadCloser, error) {
return crypto.DecryptFrom(k.master, rd)
}
// Master returns the master keys for this repository. Only included for
// debug purposes.
func (k *Key) Master() *crypto.Key {
return k.master
}
// User returns the user keys for this key. Only included for debug purposes.
func (k *Key) User() *crypto.Key {
return k.user
}
func (k *Key) String() string { func (k *Key) String() string {
if k == nil { if k == nil {
return "<Key nil>" return "<Key nil>"

View file

@ -574,7 +574,7 @@ func (s *Server) SearchKey(password string) error {
return err return err
} }
s.key = key.Master() s.key = key.master
s.keyName = key.Name() s.keyName = key.Name()
return s.loadConfig(&s.Config) return s.loadConfig(&s.Config)
} }
@ -595,7 +595,7 @@ func (s *Server) CreateMasterKey(password string) error {
return err return err
} }
s.key = key.Master() s.key = key.master
s.keyName = key.Name() s.keyName = key.Name()
return s.createConfig() return s.createConfig()
} }