2018-10-15 18:44:15 +00:00
|
|
|
package writefreely
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type keychain struct {
|
2018-10-17 00:30:38 +00:00
|
|
|
emailKey, cookieAuthKey, cookieKey []byte
|
2018-10-15 18:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func initKeys(app *app) error {
|
|
|
|
var err error
|
|
|
|
app.keys = &keychain{}
|
|
|
|
|
2018-10-17 00:30:38 +00:00
|
|
|
app.keys.emailKey, err = ioutil.ReadFile("keys/email.aes256")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-10-15 18:44:15 +00:00
|
|
|
app.keys.cookieAuthKey, err = ioutil.ReadFile("keys/cookies_auth.aes256")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
app.keys.cookieKey, err = ioutil.ReadFile("keys/cookies_enc.aes256")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|