2015-05-28 21:37:20 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
func (c *Sys) RekeyStatus() (*RekeyStatusResponse, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/rekey/init")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyStatusResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyRecoveryKeyStatus() (*RekeyStatusResponse, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/rekey-recovery-key/init")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyStatusResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-02-12 19:24:36 +00:00
|
|
|
func (c *Sys) RekeyInit(config *RekeyInitRequest) (*RekeyStatusResponse, error) {
|
2015-05-28 21:37:20 +00:00
|
|
|
r := c.c.NewRequest("PUT", "/v1/sys/rekey/init")
|
|
|
|
if err := r.SetJSONBody(config); err != nil {
|
2016-02-12 19:24:36 +00:00
|
|
|
return nil, err
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := c.c.RawRequest(r)
|
2016-02-12 19:24:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|
2016-02-12 19:24:36 +00:00
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyStatusResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyRecoveryKeyInit(config *RekeyInitRequest) (*RekeyStatusResponse, error) {
|
|
|
|
r := c.c.NewRequest("PUT", "/v1/sys/rekey-recovery-key/init")
|
|
|
|
if err := r.SetJSONBody(config); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyStatusResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2015-05-28 21:37:20 +00:00
|
|
|
func (c *Sys) RekeyCancel() error {
|
|
|
|
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/init")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err == nil {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyRecoveryKeyCancel() error {
|
|
|
|
r := c.c.NewRequest("DELETE", "/v1/sys/rekey-recovery-key/init")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err == nil {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-12-16 21:56:15 +00:00
|
|
|
func (c *Sys) RekeyUpdate(shard, nonce string) (*RekeyUpdateResponse, error) {
|
|
|
|
body := map[string]interface{}{
|
|
|
|
"key": shard,
|
|
|
|
"nonce": nonce,
|
|
|
|
}
|
2015-05-28 21:37:20 +00:00
|
|
|
|
|
|
|
r := c.c.NewRequest("PUT", "/v1/sys/rekey/update")
|
|
|
|
if err := r.SetJSONBody(body); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyUpdateResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyRecoveryKeyUpdate(shard, nonce string) (*RekeyUpdateResponse, error) {
|
|
|
|
body := map[string]interface{}{
|
|
|
|
"key": shard,
|
|
|
|
"nonce": nonce,
|
|
|
|
}
|
|
|
|
|
|
|
|
r := c.c.NewRequest("PUT", "/v1/sys/rekey-recovery-key/update")
|
|
|
|
if err := r.SetJSONBody(body); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyUpdateResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-01-08 19:09:40 +00:00
|
|
|
func (c *Sys) RekeyRetrieveBackup() (*RekeyRetrieveResponse, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/rekey/backup")
|
2015-12-16 21:56:15 +00:00
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyRetrieveResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyRetrieveRecoveryBackup() (*RekeyRetrieveResponse, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/rekey/recovery-backup")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result RekeyRetrieveResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
2016-01-08 19:09:40 +00:00
|
|
|
func (c *Sys) RekeyDeleteBackup() error {
|
|
|
|
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/backup")
|
2015-12-16 21:56:15 +00:00
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err == nil {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:44:22 +00:00
|
|
|
func (c *Sys) RekeyDeleteRecoveryBackup() error {
|
|
|
|
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/recovery-backup")
|
|
|
|
resp, err := c.c.RawRequest(r)
|
|
|
|
if err == nil {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-05-28 21:37:20 +00:00
|
|
|
type RekeyInitRequest struct {
|
2015-08-25 21:24:19 +00:00
|
|
|
SecretShares int `json:"secret_shares"`
|
|
|
|
SecretThreshold int `json:"secret_threshold"`
|
2017-10-23 20:52:56 +00:00
|
|
|
StoredShares int `json:"stored_shares"`
|
2015-08-25 22:33:58 +00:00
|
|
|
PGPKeys []string `json:"pgp_keys"`
|
2015-12-16 21:56:15 +00:00
|
|
|
Backup bool
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RekeyStatusResponse struct {
|
2018-02-12 23:12:16 +00:00
|
|
|
Nonce string `json:"nonce"`
|
|
|
|
Started bool `json:"started"`
|
|
|
|
T int `json:"t"`
|
|
|
|
N int `json:"n"`
|
|
|
|
Progress int `json:"progress"`
|
|
|
|
Required int `json:"required"`
|
2015-12-16 21:56:15 +00:00
|
|
|
PGPFingerprints []string `json:"pgp_fingerprints"`
|
2018-02-12 23:12:16 +00:00
|
|
|
Backup bool `json:"backup"`
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RekeyUpdateResponse struct {
|
2018-02-12 23:12:16 +00:00
|
|
|
Nonce string `json:"nonce"`
|
|
|
|
Complete bool `json:"complete"`
|
|
|
|
Keys []string `json:"keys"`
|
2016-08-15 20:01:15 +00:00
|
|
|
KeysB64 []string `json:"keys_base64"`
|
2015-12-16 21:56:15 +00:00
|
|
|
PGPFingerprints []string `json:"pgp_fingerprints"`
|
2018-02-12 23:12:16 +00:00
|
|
|
Backup bool `json:"backup"`
|
2015-12-16 21:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RekeyRetrieveResponse struct {
|
2018-02-12 23:12:16 +00:00
|
|
|
Nonce string `json:"nonce"`
|
|
|
|
Keys map[string][]string `json:"keys"`
|
2016-08-15 20:01:15 +00:00
|
|
|
KeysB64 map[string][]string `json:"keys_base64"`
|
2015-05-28 21:37:20 +00:00
|
|
|
}
|