|
|
3aa8f6 |
From 31b404f4a08322a5cf06b1d0637a4ada4323cbb1 Mon Sep 17 00:00:00 2001
|
|
|
3aa8f6 |
From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= <mitr@redhat.com>
|
|
|
3aa8f6 |
Date: Thu, 20 Feb 2020 16:30:08 +0100
|
|
|
3aa8f6 |
Subject: [PATCH 1/2] Remove vendor/src/github.com/mtrmac/gpgme/
|
|
|
3aa8f6 |
MIME-Version: 1.0
|
|
|
3aa8f6 |
Content-Type: text/plain; charset=UTF-8
|
|
|
3aa8f6 |
Content-Transfer-Encoding: 8bit
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
This seems to be a mistaken commit of an intermediate build state
|
|
|
3aa8f6 |
in the old times when vendoring was used via a GOPATH at vendor/src/...
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
|
|
|
3aa8f6 |
---
|
|
|
3aa8f6 |
vendor/src/github.com/mtrmac/gpgme/LICENSE | 12 -
|
|
|
3aa8f6 |
.../src/github.com/mtrmac/gpgme/callbacks.go | 42 -
|
|
|
3aa8f6 |
vendor/src/github.com/mtrmac/gpgme/data.go | 191 -----
|
|
|
3aa8f6 |
vendor/src/github.com/mtrmac/gpgme/go_gpgme.c | 89 ---
|
|
|
3aa8f6 |
vendor/src/github.com/mtrmac/gpgme/go_gpgme.h | 37 -
|
|
|
3aa8f6 |
vendor/src/github.com/mtrmac/gpgme/gpgme.go | 740 ------------------
|
|
|
3aa8f6 |
6 files changed, 1111 deletions(-)
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/LICENSE
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/callbacks.go
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
delete mode 100644 vendor/src/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/LICENSE b/vendor/src/github.com/mtrmac/gpgme/LICENSE
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index 06d4ab77316f..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/LICENSE
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,12 +0,0 @@
|
|
|
3aa8f6 |
-Copyright (c) 2015, James Fargher <proglottis@gmail.com>
|
|
|
3aa8f6 |
-All rights reserved.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/callbacks.go b/vendor/src/github.com/mtrmac/gpgme/callbacks.go
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index d1dc610d42a8..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/callbacks.go
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,42 +0,0 @@
|
|
|
3aa8f6 |
-package gpgme
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-import (
|
|
|
3aa8f6 |
- "sync"
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-var callbacks struct {
|
|
|
3aa8f6 |
- sync.Mutex
|
|
|
3aa8f6 |
- m map[uintptr]interface{}
|
|
|
3aa8f6 |
- c uintptr
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func callbackAdd(v interface{}) uintptr {
|
|
|
3aa8f6 |
- callbacks.Lock()
|
|
|
3aa8f6 |
- defer callbacks.Unlock()
|
|
|
3aa8f6 |
- if callbacks.m == nil {
|
|
|
3aa8f6 |
- callbacks.m = make(map[uintptr]interface{})
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- callbacks.c++
|
|
|
3aa8f6 |
- ret := callbacks.c
|
|
|
3aa8f6 |
- callbacks.m[ret] = v
|
|
|
3aa8f6 |
- return ret
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func callbackLookup(c uintptr) interface{} {
|
|
|
3aa8f6 |
- callbacks.Lock()
|
|
|
3aa8f6 |
- defer callbacks.Unlock()
|
|
|
3aa8f6 |
- ret := callbacks.m[c]
|
|
|
3aa8f6 |
- if ret == nil {
|
|
|
3aa8f6 |
- panic("callback pointer not found")
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return ret
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func callbackDelete(c uintptr) {
|
|
|
3aa8f6 |
- callbacks.Lock()
|
|
|
3aa8f6 |
- defer callbacks.Unlock()
|
|
|
3aa8f6 |
- if callbacks.m[c] == nil {
|
|
|
3aa8f6 |
- panic("callback pointer not found")
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- delete(callbacks.m, c)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/data.go b/vendor/src/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index eebc9726347d..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,191 +0,0 @@
|
|
|
3aa8f6 |
-package gpgme
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// #include <string.h>
|
|
|
3aa8f6 |
-// #include <gpgme.h>
|
|
|
3aa8f6 |
-// #include <errno.h>
|
|
|
3aa8f6 |
-// #include "go_gpgme.h"
|
|
|
3aa8f6 |
-import "C"
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-import (
|
|
|
3aa8f6 |
- "io"
|
|
|
3aa8f6 |
- "os"
|
|
|
3aa8f6 |
- "runtime"
|
|
|
3aa8f6 |
- "unsafe"
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- SeekSet = C.SEEK_SET
|
|
|
3aa8f6 |
- SeekCur = C.SEEK_CUR
|
|
|
3aa8f6 |
- SeekEnd = C.SEEK_END
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-//export gogpgme_readfunc
|
|
|
3aa8f6 |
-func gogpgme_readfunc(handle, buffer unsafe.Pointer, size C.size_t) C.ssize_t {
|
|
|
3aa8f6 |
- d := callbackLookup(uintptr(handle)).(*Data)
|
|
|
3aa8f6 |
- if len(d.buf) < int(size) {
|
|
|
3aa8f6 |
- d.buf = make([]byte, size)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- n, err := d.r.Read(d.buf[:size])
|
|
|
3aa8f6 |
- if err != nil && err != io.EOF {
|
|
|
3aa8f6 |
- C.gpgme_err_set_errno(C.EIO)
|
|
|
3aa8f6 |
- return -1
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- C.memcpy(buffer, unsafe.Pointer(&d.buf[0]), C.size_t(n))
|
|
|
3aa8f6 |
- return C.ssize_t(n)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-//export gogpgme_writefunc
|
|
|
3aa8f6 |
-func gogpgme_writefunc(handle, buffer unsafe.Pointer, size C.size_t) C.ssize_t {
|
|
|
3aa8f6 |
- d := callbackLookup(uintptr(handle)).(*Data)
|
|
|
3aa8f6 |
- if len(d.buf) < int(size) {
|
|
|
3aa8f6 |
- d.buf = make([]byte, size)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- C.memcpy(unsafe.Pointer(&d.buf[0]), buffer, C.size_t(size))
|
|
|
3aa8f6 |
- n, err := d.w.Write(d.buf[:size])
|
|
|
3aa8f6 |
- if err != nil && err != io.EOF {
|
|
|
3aa8f6 |
- C.gpgme_err_set_errno(C.EIO)
|
|
|
3aa8f6 |
- return -1
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return C.ssize_t(n)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-//export gogpgme_seekfunc
|
|
|
3aa8f6 |
-func gogpgme_seekfunc(handle unsafe.Pointer, offset C.off_t, whence C.int) C.off_t {
|
|
|
3aa8f6 |
- d := callbackLookup(uintptr(handle)).(*Data)
|
|
|
3aa8f6 |
- n, err := d.s.Seek(int64(offset), int(whence))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- C.gpgme_err_set_errno(C.EIO)
|
|
|
3aa8f6 |
- return -1
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return C.off_t(n)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// The Data buffer used to communicate with GPGME
|
|
|
3aa8f6 |
-type Data struct {
|
|
|
3aa8f6 |
- dh C.gpgme_data_t
|
|
|
3aa8f6 |
- buf []byte
|
|
|
3aa8f6 |
- cbs C.struct_gpgme_data_cbs
|
|
|
3aa8f6 |
- r io.Reader
|
|
|
3aa8f6 |
- w io.Writer
|
|
|
3aa8f6 |
- s io.Seeker
|
|
|
3aa8f6 |
- cbc uintptr
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func newData() *Data {
|
|
|
3aa8f6 |
- d := &Data{}
|
|
|
3aa8f6 |
- runtime.SetFinalizer(d, (*Data).Close)
|
|
|
3aa8f6 |
- return d
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewData returns a new memory based data buffer
|
|
|
3aa8f6 |
-func NewData() (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- return d, handleError(C.gpgme_data_new(&d.dh))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataFile returns a new file based data buffer
|
|
|
3aa8f6 |
-func NewDataFile(f *os.File) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- return d, handleError(C.gpgme_data_new_from_fd(&d.dh, C.int(f.Fd())))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataBytes returns a new memory based data buffer that contains `b` bytes
|
|
|
3aa8f6 |
-func NewDataBytes(b []byte) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- var cb *C.char
|
|
|
3aa8f6 |
- if len(b) != 0 {
|
|
|
3aa8f6 |
- cb = (*C.char)(unsafe.Pointer(&b[0]))
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return d, handleError(C.gpgme_data_new_from_mem(&d.dh, cb, C.size_t(len(b)), 1))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataReader returns a new callback based data buffer
|
|
|
3aa8f6 |
-func NewDataReader(r io.Reader) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- d.r = r
|
|
|
3aa8f6 |
- d.cbs.read = C.gpgme_data_read_cb_t(C.gogpgme_readfunc)
|
|
|
3aa8f6 |
- cbc := callbackAdd(d)
|
|
|
3aa8f6 |
- d.cbc = cbc
|
|
|
3aa8f6 |
- return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataWriter returns a new callback based data buffer
|
|
|
3aa8f6 |
-func NewDataWriter(w io.Writer) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- d.w = w
|
|
|
3aa8f6 |
- d.cbs.write = C.gpgme_data_write_cb_t(C.gogpgme_writefunc)
|
|
|
3aa8f6 |
- cbc := callbackAdd(d)
|
|
|
3aa8f6 |
- d.cbc = cbc
|
|
|
3aa8f6 |
- return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataReadWriter returns a new callback based data buffer
|
|
|
3aa8f6 |
-func NewDataReadWriter(rw io.ReadWriter) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- d.r = rw
|
|
|
3aa8f6 |
- d.w = rw
|
|
|
3aa8f6 |
- d.cbs.read = C.gpgme_data_read_cb_t(C.gogpgme_readfunc)
|
|
|
3aa8f6 |
- d.cbs.write = C.gpgme_data_write_cb_t(C.gogpgme_writefunc)
|
|
|
3aa8f6 |
- cbc := callbackAdd(d)
|
|
|
3aa8f6 |
- d.cbc = cbc
|
|
|
3aa8f6 |
- return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// NewDataReadWriteSeeker returns a new callback based data buffer
|
|
|
3aa8f6 |
-func NewDataReadWriteSeeker(rw io.ReadWriteSeeker) (*Data, error) {
|
|
|
3aa8f6 |
- d := newData()
|
|
|
3aa8f6 |
- d.r = rw
|
|
|
3aa8f6 |
- d.w = rw
|
|
|
3aa8f6 |
- d.s = rw
|
|
|
3aa8f6 |
- d.cbs.read = C.gpgme_data_read_cb_t(C.gogpgme_readfunc)
|
|
|
3aa8f6 |
- d.cbs.write = C.gpgme_data_write_cb_t(C.gogpgme_writefunc)
|
|
|
3aa8f6 |
- d.cbs.seek = C.gpgme_data_seek_cb_t(C.gogpgme_seekfunc)
|
|
|
3aa8f6 |
- cbc := callbackAdd(d)
|
|
|
3aa8f6 |
- d.cbc = cbc
|
|
|
3aa8f6 |
- return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Close releases any resources associated with the data buffer
|
|
|
3aa8f6 |
-func (d *Data) Close() error {
|
|
|
3aa8f6 |
- if d.dh == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if d.cbc > 0 {
|
|
|
3aa8f6 |
- callbackDelete(d.cbc)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- _, err := C.gpgme_data_release(d.dh)
|
|
|
3aa8f6 |
- d.dh = nil
|
|
|
3aa8f6 |
- return err
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (d *Data) Write(p []byte) (int, error) {
|
|
|
3aa8f6 |
- n, err := C.gpgme_data_write(d.dh, unsafe.Pointer(&p[0]), C.size_t(len(p)))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return 0, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if n == 0 {
|
|
|
3aa8f6 |
- return 0, io.EOF
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return int(n), nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (d *Data) Read(p []byte) (int, error) {
|
|
|
3aa8f6 |
- n, err := C.gpgme_data_read(d.dh, unsafe.Pointer(&p[0]), C.size_t(len(p)))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return 0, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if n == 0 {
|
|
|
3aa8f6 |
- return 0, io.EOF
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return int(n), nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (d *Data) Seek(offset int64, whence int) (int64, error) {
|
|
|
3aa8f6 |
- n, err := C.gpgme_data_seek(d.dh, C.off_t(offset), C.int(whence))
|
|
|
3aa8f6 |
- return int64(n), err
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Name returns the associated filename if any
|
|
|
3aa8f6 |
-func (d *Data) Name() string {
|
|
|
3aa8f6 |
- return C.GoString(C.gpgme_data_get_file_name(d.dh))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/go_gpgme.c b/vendor/src/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index b887574e0cb9..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,89 +0,0 @@
|
|
|
3aa8f6 |
-#include "go_gpgme.h"
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-gpgme_error_t gogpgme_data_new_from_cbs(gpgme_data_t *dh, gpgme_data_cbs_t cbs, uintptr_t handle) {
|
|
|
3aa8f6 |
- return gpgme_data_new_from_cbs(dh, cbs, (void *)handle);
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-void gogpgme_set_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, uintptr_t handle) {
|
|
|
3aa8f6 |
- gpgme_set_passphrase_cb(ctx, cb, (void *)handle);
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_revoked(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->revoked;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_expired(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->expired;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_disabled(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->disabled;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_invalid(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->invalid;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_can_encrypt(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->can_encrypt;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_can_sign(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->can_sign;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_can_certify(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->can_certify;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_secret(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->secret;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_can_authenticate(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->can_authenticate;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int key_is_qualified(gpgme_key_t k) {
|
|
|
3aa8f6 |
- return k->is_qualified;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int signature_wrong_key_usage(gpgme_signature_t s) {
|
|
|
3aa8f6 |
- return s->wrong_key_usage;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int signature_pka_trust(gpgme_signature_t s) {
|
|
|
3aa8f6 |
- return s->pka_trust;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int signature_chain_model(gpgme_signature_t s) {
|
|
|
3aa8f6 |
- return s->chain_model;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int subkey_revoked(gpgme_subkey_t k) {
|
|
|
3aa8f6 |
- return k->revoked;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int subkey_expired(gpgme_subkey_t k) {
|
|
|
3aa8f6 |
- return k->expired;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int subkey_disabled(gpgme_subkey_t k) {
|
|
|
3aa8f6 |
- return k->disabled;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int subkey_invalid(gpgme_subkey_t k) {
|
|
|
3aa8f6 |
- return k->invalid;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int subkey_secret(gpgme_subkey_t k) {
|
|
|
3aa8f6 |
- return k->secret;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int uid_revoked(gpgme_user_id_t u) {
|
|
|
3aa8f6 |
- return u->revoked;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-unsigned int uid_invalid(gpgme_user_id_t u) {
|
|
|
3aa8f6 |
- return u->invalid;
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/go_gpgme.h b/vendor/src/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index a3678b127ac7..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,37 +0,0 @@
|
|
|
3aa8f6 |
-#ifndef GO_GPGME_H
|
|
|
3aa8f6 |
-#define GO_GPGME_H
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-#define _FILE_OFFSET_BITS 64
|
|
|
3aa8f6 |
-#include <stdint.h>
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-#include <gpgme.h>
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-extern ssize_t gogpgme_readfunc(void *handle, void *buffer, size_t size);
|
|
|
3aa8f6 |
-extern ssize_t gogpgme_writefunc(void *handle, void *buffer, size_t size);
|
|
|
3aa8f6 |
-extern off_t gogpgme_seekfunc(void *handle, off_t offset, int whence);
|
|
|
3aa8f6 |
-extern gpgme_error_t gogpgme_passfunc(void *hook, char *uid_hint, char *passphrase_info, int prev_was_bad, int fd);
|
|
|
3aa8f6 |
-extern gpgme_error_t gogpgme_data_new_from_cbs(gpgme_data_t *dh, gpgme_data_cbs_t cbs, uintptr_t handle);
|
|
|
3aa8f6 |
-extern void gogpgme_set_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, uintptr_t handle);
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-extern unsigned int key_revoked(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_expired(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_disabled(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_invalid(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_can_encrypt(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_can_sign(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_can_certify(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_secret(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_can_authenticate(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int key_is_qualified(gpgme_key_t k);
|
|
|
3aa8f6 |
-extern unsigned int signature_wrong_key_usage(gpgme_signature_t s);
|
|
|
3aa8f6 |
-extern unsigned int signature_pka_trust(gpgme_signature_t s);
|
|
|
3aa8f6 |
-extern unsigned int signature_chain_model(gpgme_signature_t s);
|
|
|
3aa8f6 |
-extern unsigned int subkey_revoked(gpgme_subkey_t k);
|
|
|
3aa8f6 |
-extern unsigned int subkey_expired(gpgme_subkey_t k);
|
|
|
3aa8f6 |
-extern unsigned int subkey_disabled(gpgme_subkey_t k);
|
|
|
3aa8f6 |
-extern unsigned int subkey_invalid(gpgme_subkey_t k);
|
|
|
3aa8f6 |
-extern unsigned int subkey_secret(gpgme_subkey_t k);
|
|
|
3aa8f6 |
-extern unsigned int uid_revoked(gpgme_user_id_t u);
|
|
|
3aa8f6 |
-extern unsigned int uid_invalid(gpgme_user_id_t u);
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-#endif
|
|
|
3aa8f6 |
diff --git a/vendor/src/github.com/mtrmac/gpgme/gpgme.go b/vendor/src/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
deleted file mode 100644
|
|
|
3aa8f6 |
index 5f1793eab32d..000000000000
|
|
|
3aa8f6 |
--- a/vendor/src/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
+++ /dev/null
|
|
|
3aa8f6 |
@@ -1,740 +0,0 @@
|
|
|
3aa8f6 |
-// Package gpgme provides a Go wrapper for the GPGME library
|
|
|
3aa8f6 |
-package gpgme
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// #cgo LDFLAGS: -lgpgme -lassuan -lgpg-error
|
|
|
3aa8f6 |
-// #cgo CPPFLAGS: -D_FILE_OFFSET_BITS=64
|
|
|
3aa8f6 |
-// #include <stdlib.h>
|
|
|
3aa8f6 |
-// #include <gpgme.h>
|
|
|
3aa8f6 |
-// #include "go_gpgme.h"
|
|
|
3aa8f6 |
-import "C"
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-import (
|
|
|
3aa8f6 |
- "io"
|
|
|
3aa8f6 |
- "os"
|
|
|
3aa8f6 |
- "runtime"
|
|
|
3aa8f6 |
- "time"
|
|
|
3aa8f6 |
- "unsafe"
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-var Version string
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func init() {
|
|
|
3aa8f6 |
- Version = C.GoString(C.gpgme_check_version(nil))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Callback is the function that is called when a passphrase is required
|
|
|
3aa8f6 |
-type Callback func(uidHint string, prevWasBad bool, f *os.File) error
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-//export gogpgme_passfunc
|
|
|
3aa8f6 |
-func gogpgme_passfunc(hook unsafe.Pointer, uid_hint, passphrase_info *C.char, prev_was_bad, fd C.int) C.gpgme_error_t {
|
|
|
3aa8f6 |
- c := callbackLookup(uintptr(hook)).(*Context)
|
|
|
3aa8f6 |
- go_uid_hint := C.GoString(uid_hint)
|
|
|
3aa8f6 |
- f := os.NewFile(uintptr(fd), go_uid_hint)
|
|
|
3aa8f6 |
- defer f.Close()
|
|
|
3aa8f6 |
- err := c.callback(go_uid_hint, prev_was_bad != 0, f)
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return C.GPG_ERR_CANCELED
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type Protocol int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- ProtocolOpenPGP Protocol = C.GPGME_PROTOCOL_OpenPGP
|
|
|
3aa8f6 |
- ProtocolCMS Protocol = C.GPGME_PROTOCOL_CMS
|
|
|
3aa8f6 |
- ProtocolGPGConf Protocol = C.GPGME_PROTOCOL_GPGCONF
|
|
|
3aa8f6 |
- ProtocolAssuan Protocol = C.GPGME_PROTOCOL_ASSUAN
|
|
|
3aa8f6 |
- ProtocolG13 Protocol = C.GPGME_PROTOCOL_G13
|
|
|
3aa8f6 |
- ProtocolUIServer Protocol = C.GPGME_PROTOCOL_UISERVER
|
|
|
3aa8f6 |
- // ProtocolSpawn Protocol = C.GPGME_PROTOCOL_SPAWN // Unavailable in 1.4.3
|
|
|
3aa8f6 |
- ProtocolDefault Protocol = C.GPGME_PROTOCOL_DEFAULT
|
|
|
3aa8f6 |
- ProtocolUnknown Protocol = C.GPGME_PROTOCOL_UNKNOWN
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type PinEntryMode int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// const ( // Unavailable in 1.3.2
|
|
|
3aa8f6 |
-// PinEntryDefault PinEntryMode = C.GPGME_PINENTRY_MODE_DEFAULT
|
|
|
3aa8f6 |
-// PinEntryAsk PinEntryMode = C.GPGME_PINENTRY_MODE_ASK
|
|
|
3aa8f6 |
-// PinEntryCancel PinEntryMode = C.GPGME_PINENTRY_MODE_CANCEL
|
|
|
3aa8f6 |
-// PinEntryError PinEntryMode = C.GPGME_PINENTRY_MODE_ERROR
|
|
|
3aa8f6 |
-// PinEntryLoopback PinEntryMode = C.GPGME_PINENTRY_MODE_LOOPBACK
|
|
|
3aa8f6 |
-// )
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type EncryptFlag uint
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- EncryptAlwaysTrust EncryptFlag = C.GPGME_ENCRYPT_ALWAYS_TRUST
|
|
|
3aa8f6 |
- EncryptNoEncryptTo EncryptFlag = C.GPGME_ENCRYPT_NO_ENCRYPT_TO
|
|
|
3aa8f6 |
- EncryptPrepare EncryptFlag = C.GPGME_ENCRYPT_PREPARE
|
|
|
3aa8f6 |
- EncryptExceptSign EncryptFlag = C.GPGME_ENCRYPT_EXPECT_SIGN
|
|
|
3aa8f6 |
- // EncryptNoCompress EncryptFlag = C.GPGME_ENCRYPT_NO_COMPRESS // Unavailable in 1.4.3
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type HashAlgo int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// const values for HashAlgo values should be added when necessary.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type KeyListMode uint
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- KeyListModeLocal KeyListMode = C.GPGME_KEYLIST_MODE_LOCAL
|
|
|
3aa8f6 |
- KeyListModeExtern KeyListMode = C.GPGME_KEYLIST_MODE_EXTERN
|
|
|
3aa8f6 |
- KeyListModeSigs KeyListMode = C.GPGME_KEYLIST_MODE_SIGS
|
|
|
3aa8f6 |
- KeyListModeSigNotations KeyListMode = C.GPGME_KEYLIST_MODE_SIG_NOTATIONS
|
|
|
3aa8f6 |
- // KeyListModeWithSecret KeyListMode = C.GPGME_KEYLIST_MODE_WITH_SECRET // Unavailable in 1.4.3
|
|
|
3aa8f6 |
- KeyListModeEphemeral KeyListMode = C.GPGME_KEYLIST_MODE_EPHEMERAL
|
|
|
3aa8f6 |
- KeyListModeModeValidate KeyListMode = C.GPGME_KEYLIST_MODE_VALIDATE
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type PubkeyAlgo int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// const values for PubkeyAlgo values should be added when necessary.
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type SigMode int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- SigModeNormal SigMode = C.GPGME_SIG_MODE_NORMAL
|
|
|
3aa8f6 |
- SigModeDetach SigMode = C.GPGME_SIG_MODE_DETACH
|
|
|
3aa8f6 |
- SigModeClear SigMode = C.GPGME_SIG_MODE_CLEAR
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type SigSum int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- SigSumValid SigSum = C.GPGME_SIGSUM_VALID
|
|
|
3aa8f6 |
- SigSumGreen SigSum = C.GPGME_SIGSUM_GREEN
|
|
|
3aa8f6 |
- SigSumRed SigSum = C.GPGME_SIGSUM_RED
|
|
|
3aa8f6 |
- SigSumKeyRevoked SigSum = C.GPGME_SIGSUM_KEY_REVOKED
|
|
|
3aa8f6 |
- SigSumKeyExpired SigSum = C.GPGME_SIGSUM_KEY_EXPIRED
|
|
|
3aa8f6 |
- SigSumSigExpired SigSum = C.GPGME_SIGSUM_SIG_EXPIRED
|
|
|
3aa8f6 |
- SigSumKeyMissing SigSum = C.GPGME_SIGSUM_KEY_MISSING
|
|
|
3aa8f6 |
- SigSumCRLMissing SigSum = C.GPGME_SIGSUM_CRL_MISSING
|
|
|
3aa8f6 |
- SigSumCRLTooOld SigSum = C.GPGME_SIGSUM_CRL_TOO_OLD
|
|
|
3aa8f6 |
- SigSumBadPolicy SigSum = C.GPGME_SIGSUM_BAD_POLICY
|
|
|
3aa8f6 |
- SigSumSysError SigSum = C.GPGME_SIGSUM_SYS_ERROR
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type Validity int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- ValidityUnknown Validity = C.GPGME_VALIDITY_UNKNOWN
|
|
|
3aa8f6 |
- ValidityUndefined Validity = C.GPGME_VALIDITY_UNDEFINED
|
|
|
3aa8f6 |
- ValidityNever Validity = C.GPGME_VALIDITY_NEVER
|
|
|
3aa8f6 |
- ValidityMarginal Validity = C.GPGME_VALIDITY_MARGINAL
|
|
|
3aa8f6 |
- ValidityFull Validity = C.GPGME_VALIDITY_FULL
|
|
|
3aa8f6 |
- ValidityUltimate Validity = C.GPGME_VALIDITY_ULTIMATE
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type ErrorCode int
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- ErrorNoError ErrorCode = C.GPG_ERR_NO_ERROR
|
|
|
3aa8f6 |
- ErrorEOF ErrorCode = C.GPG_ERR_EOF
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Error is a wrapper for GPGME errors
|
|
|
3aa8f6 |
-type Error struct {
|
|
|
3aa8f6 |
- err C.gpgme_error_t
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e Error) Code() ErrorCode {
|
|
|
3aa8f6 |
- return ErrorCode(C.gpgme_err_code(e.err))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e Error) Error() string {
|
|
|
3aa8f6 |
- return C.GoString(C.gpgme_strerror(e.err))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func handleError(err C.gpgme_error_t) error {
|
|
|
3aa8f6 |
- e := Error{err: err}
|
|
|
3aa8f6 |
- if e.Code() == ErrorNoError {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return e
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func cbool(b bool) C.int {
|
|
|
3aa8f6 |
- if b {
|
|
|
3aa8f6 |
- return 1
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func EngineCheckVersion(p Protocol) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_engine_check_version(C.gpgme_protocol_t(p)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type EngineInfo struct {
|
|
|
3aa8f6 |
- info C.gpgme_engine_info_t
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) Next() *EngineInfo {
|
|
|
3aa8f6 |
- if e.info.next == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &EngineInfo{info: e.info.next}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(e.info.protocol)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) FileName() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.file_name)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) Version() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.version)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) RequiredVersion() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.req_version)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (e *EngineInfo) HomeDir() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.home_dir)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func GetEngineInfo() (*EngineInfo, error) {
|
|
|
3aa8f6 |
- info := &EngineInfo{}
|
|
|
3aa8f6 |
- return info, handleError(C.gpgme_get_engine_info(&info.info))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func SetEngineInfo(proto Protocol, fileName, homeDir string) error {
|
|
|
3aa8f6 |
- var cfn, chome *C.char
|
|
|
3aa8f6 |
- if fileName != "" {
|
|
|
3aa8f6 |
- cfn = C.CString(fileName)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(cfn))
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if homeDir != "" {
|
|
|
3aa8f6 |
- chome = C.CString(homeDir)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(chome))
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return handleError(C.gpgme_set_engine_info(C.gpgme_protocol_t(proto), cfn, chome))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func FindKeys(pattern string, secretOnly bool) ([]*Key, error) {
|
|
|
3aa8f6 |
- var keys []*Key
|
|
|
3aa8f6 |
- ctx, err := New()
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return keys, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- defer ctx.Release()
|
|
|
3aa8f6 |
- if err := ctx.KeyListStart(pattern, secretOnly); err != nil {
|
|
|
3aa8f6 |
- return keys, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- defer ctx.KeyListEnd()
|
|
|
3aa8f6 |
- for ctx.KeyListNext() {
|
|
|
3aa8f6 |
- keys = append(keys, ctx.Key)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if ctx.KeyError != nil {
|
|
|
3aa8f6 |
- return keys, ctx.KeyError
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return keys, nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func Decrypt(r io.Reader) (*Data, error) {
|
|
|
3aa8f6 |
- ctx, err := New()
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return nil, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- defer ctx.Release()
|
|
|
3aa8f6 |
- cipher, err := NewDataReader(r)
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return nil, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- defer cipher.Close()
|
|
|
3aa8f6 |
- plain, err := NewData()
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return nil, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- err = ctx.Decrypt(cipher, plain)
|
|
|
3aa8f6 |
- plain.Seek(0, SeekSet)
|
|
|
3aa8f6 |
- return plain, err
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type Context struct {
|
|
|
3aa8f6 |
- Key *Key
|
|
|
3aa8f6 |
- KeyError error
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
- callback Callback
|
|
|
3aa8f6 |
- cbc uintptr
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
- ctx C.gpgme_ctx_t
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func New() (*Context, error) {
|
|
|
3aa8f6 |
- c := &Context{}
|
|
|
3aa8f6 |
- err := C.gpgme_new(&c.ctx)
|
|
|
3aa8f6 |
- runtime.SetFinalizer(c, (*Context).Release)
|
|
|
3aa8f6 |
- return c, handleError(err)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Release() {
|
|
|
3aa8f6 |
- if c.ctx == nil {
|
|
|
3aa8f6 |
- return
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if c.cbc > 0 {
|
|
|
3aa8f6 |
- callbackDelete(c.cbc)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- C.gpgme_release(c.ctx)
|
|
|
3aa8f6 |
- c.ctx = nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetArmor(yes bool) {
|
|
|
3aa8f6 |
- C.gpgme_set_armor(c.ctx, cbool(yes))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Armor() bool {
|
|
|
3aa8f6 |
- return C.gpgme_get_armor(c.ctx) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetTextMode(yes bool) {
|
|
|
3aa8f6 |
- C.gpgme_set_textmode(c.ctx, cbool(yes))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) TextMode() bool {
|
|
|
3aa8f6 |
- return C.gpgme_get_textmode(c.ctx) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetProtocol(p Protocol) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_set_protocol(c.ctx, C.gpgme_protocol_t(p)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(C.gpgme_get_protocol(c.ctx))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetKeyListMode(m KeyListMode) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_set_keylist_mode(c.ctx, C.gpgme_keylist_mode_t(m)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) KeyListMode() KeyListMode {
|
|
|
3aa8f6 |
- return KeyListMode(C.gpgme_get_keylist_mode(c.ctx))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Unavailable in 1.3.2:
|
|
|
3aa8f6 |
-// func (c *Context) SetPinEntryMode(m PinEntryMode) error {
|
|
|
3aa8f6 |
-// return handleError(C.gpgme_set_pinentry_mode(c.ctx, C.gpgme_pinentry_mode_t(m)))
|
|
|
3aa8f6 |
-// }
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// Unavailable in 1.3.2:
|
|
|
3aa8f6 |
-// func (c *Context) PinEntryMode() PinEntryMode {
|
|
|
3aa8f6 |
-// return PinEntryMode(C.gpgme_get_pinentry_mode(c.ctx))
|
|
|
3aa8f6 |
-// }
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetCallback(callback Callback) error {
|
|
|
3aa8f6 |
- var err error
|
|
|
3aa8f6 |
- c.callback = callback
|
|
|
3aa8f6 |
- if c.cbc > 0 {
|
|
|
3aa8f6 |
- callbackDelete(c.cbc)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if callback != nil {
|
|
|
3aa8f6 |
- cbc := callbackAdd(c)
|
|
|
3aa8f6 |
- c.cbc = cbc
|
|
|
3aa8f6 |
- _, err = C.gogpgme_set_passphrase_cb(c.ctx, C.gpgme_passphrase_cb_t(C.gogpgme_passfunc), C.uintptr_t(cbc))
|
|
|
3aa8f6 |
- } else {
|
|
|
3aa8f6 |
- c.cbc = 0
|
|
|
3aa8f6 |
- _, err = C.gogpgme_set_passphrase_cb(c.ctx, nil, 0)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return err
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) EngineInfo() *EngineInfo {
|
|
|
3aa8f6 |
- return &EngineInfo{info: C.gpgme_ctx_get_engine_info(c.ctx)}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) SetEngineInfo(proto Protocol, fileName, homeDir string) error {
|
|
|
3aa8f6 |
- var cfn, chome *C.char
|
|
|
3aa8f6 |
- if fileName != "" {
|
|
|
3aa8f6 |
- cfn = C.CString(fileName)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(cfn))
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if homeDir != "" {
|
|
|
3aa8f6 |
- chome = C.CString(homeDir)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(chome))
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return handleError(C.gpgme_ctx_set_engine_info(c.ctx, C.gpgme_protocol_t(proto), cfn, chome))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) KeyListStart(pattern string, secretOnly bool) error {
|
|
|
3aa8f6 |
- cpattern := C.CString(pattern)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(cpattern))
|
|
|
3aa8f6 |
- err := C.gpgme_op_keylist_start(c.ctx, cpattern, cbool(secretOnly))
|
|
|
3aa8f6 |
- return handleError(err)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) KeyListNext() bool {
|
|
|
3aa8f6 |
- c.Key = newKey()
|
|
|
3aa8f6 |
- err := handleError(C.gpgme_op_keylist_next(c.ctx, &c.Key.k))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- if e, ok := err.(Error); ok && e.Code() == ErrorEOF {
|
|
|
3aa8f6 |
- c.KeyError = nil
|
|
|
3aa8f6 |
- } else {
|
|
|
3aa8f6 |
- c.KeyError = err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return false
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- c.KeyError = nil
|
|
|
3aa8f6 |
- return true
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) KeyListEnd() error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_keylist_end(c.ctx))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) GetKey(fingerprint string, secret bool) (*Key, error) {
|
|
|
3aa8f6 |
- key := newKey()
|
|
|
3aa8f6 |
- cfpr := C.CString(fingerprint)
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(cfpr))
|
|
|
3aa8f6 |
- return key, handleError(C.gpgme_get_key(c.ctx, cfpr, &key.k, cbool(secret)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Decrypt(ciphertext, plaintext *Data) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_decrypt(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) DecryptVerify(ciphertext, plaintext *Data) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_decrypt_verify(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type Signature struct {
|
|
|
3aa8f6 |
- Summary SigSum
|
|
|
3aa8f6 |
- Fingerprint string
|
|
|
3aa8f6 |
- Status error
|
|
|
3aa8f6 |
- Timestamp time.Time
|
|
|
3aa8f6 |
- ExpTimestamp time.Time
|
|
|
3aa8f6 |
- WrongKeyUsage bool
|
|
|
3aa8f6 |
- PKATrust uint
|
|
|
3aa8f6 |
- ChainModel bool
|
|
|
3aa8f6 |
- Validity Validity
|
|
|
3aa8f6 |
- ValidityReason error
|
|
|
3aa8f6 |
- PubkeyAlgo PubkeyAlgo
|
|
|
3aa8f6 |
- HashAlgo HashAlgo
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Verify(sig, signedText, plain *Data) (string, []Signature, error) {
|
|
|
3aa8f6 |
- var signedTextPtr, plainPtr C.gpgme_data_t = nil, nil
|
|
|
3aa8f6 |
- if signedText != nil {
|
|
|
3aa8f6 |
- signedTextPtr = signedText.dh
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- if plain != nil {
|
|
|
3aa8f6 |
- plainPtr = plain.dh
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- err := handleError(C.gpgme_op_verify(c.ctx, sig.dh, signedTextPtr, plainPtr))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return "", nil, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- res := C.gpgme_op_verify_result(c.ctx)
|
|
|
3aa8f6 |
- sigs := []Signature{}
|
|
|
3aa8f6 |
- for s := res.signatures; s != nil; s = s.next {
|
|
|
3aa8f6 |
- sig := Signature{
|
|
|
3aa8f6 |
- Summary: SigSum(s.summary),
|
|
|
3aa8f6 |
- Fingerprint: C.GoString(s.fpr),
|
|
|
3aa8f6 |
- Status: handleError(s.status),
|
|
|
3aa8f6 |
- // s.notations not implemented
|
|
|
3aa8f6 |
- Timestamp: time.Unix(int64(s.timestamp), 0),
|
|
|
3aa8f6 |
- ExpTimestamp: time.Unix(int64(s.exp_timestamp), 0),
|
|
|
3aa8f6 |
- WrongKeyUsage: C.signature_wrong_key_usage(s) != 0,
|
|
|
3aa8f6 |
- PKATrust: uint(C.signature_pka_trust(s)),
|
|
|
3aa8f6 |
- ChainModel: C.signature_chain_model(s) != 0,
|
|
|
3aa8f6 |
- Validity: Validity(s.validity),
|
|
|
3aa8f6 |
- ValidityReason: handleError(s.validity_reason),
|
|
|
3aa8f6 |
- PubkeyAlgo: PubkeyAlgo(s.pubkey_algo),
|
|
|
3aa8f6 |
- HashAlgo: HashAlgo(s.hash_algo),
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- sigs = append(sigs, sig)
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return C.GoString(res.file_name), sigs, nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Encrypt(recipients []*Key, flags EncryptFlag, plaintext, ciphertext *Data) error {
|
|
|
3aa8f6 |
- size := unsafe.Sizeof(new(C.gpgme_key_t))
|
|
|
3aa8f6 |
- recp := C.calloc(C.size_t(len(recipients)+1), C.size_t(size))
|
|
|
3aa8f6 |
- defer C.free(recp)
|
|
|
3aa8f6 |
- for i := range recipients {
|
|
|
3aa8f6 |
- ptr := (*C.gpgme_key_t)(unsafe.Pointer(uintptr(recp) + size*uintptr(i)))
|
|
|
3aa8f6 |
- *ptr = recipients[i].k
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- err := C.gpgme_op_encrypt(c.ctx, (*C.gpgme_key_t)(recp), C.gpgme_encrypt_flags_t(flags), plaintext.dh, ciphertext.dh)
|
|
|
3aa8f6 |
- return handleError(err)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Sign(signers []*Key, plain, sig *Data, mode SigMode) error {
|
|
|
3aa8f6 |
- C.gpgme_signers_clear(c.ctx)
|
|
|
3aa8f6 |
- for _, k := range signers {
|
|
|
3aa8f6 |
- if err := handleError(C.gpgme_signers_add(c.ctx, k.k)); err != nil {
|
|
|
3aa8f6 |
- C.gpgme_signers_clear(c.ctx)
|
|
|
3aa8f6 |
- return err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_sign(c.ctx, plain.dh, sig.dh, C.gpgme_sig_mode_t(mode)))
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// ImportStatusFlags describes the type of ImportStatus.Status. The C API in gpgme.h simply uses "unsigned".
|
|
|
3aa8f6 |
-type ImportStatusFlags uint
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-const (
|
|
|
3aa8f6 |
- ImportNew ImportStatusFlags = C.GPGME_IMPORT_NEW
|
|
|
3aa8f6 |
- ImportUID ImportStatusFlags = C.GPGME_IMPORT_UID
|
|
|
3aa8f6 |
- ImportSIG ImportStatusFlags = C.GPGME_IMPORT_SIG
|
|
|
3aa8f6 |
- ImportSubKey ImportStatusFlags = C.GPGME_IMPORT_SUBKEY
|
|
|
3aa8f6 |
- ImportSecret ImportStatusFlags = C.GPGME_IMPORT_SECRET
|
|
|
3aa8f6 |
-)
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type ImportStatus struct {
|
|
|
3aa8f6 |
- Fingerprint string
|
|
|
3aa8f6 |
- Result error
|
|
|
3aa8f6 |
- Status ImportStatusFlags
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type ImportResult struct {
|
|
|
3aa8f6 |
- Considered int
|
|
|
3aa8f6 |
- NoUserID int
|
|
|
3aa8f6 |
- Imported int
|
|
|
3aa8f6 |
- ImportedRSA int
|
|
|
3aa8f6 |
- Unchanged int
|
|
|
3aa8f6 |
- NewUserIDs int
|
|
|
3aa8f6 |
- NewSubKeys int
|
|
|
3aa8f6 |
- NewSignatures int
|
|
|
3aa8f6 |
- NewRevocations int
|
|
|
3aa8f6 |
- SecretRead int
|
|
|
3aa8f6 |
- SecretImported int
|
|
|
3aa8f6 |
- SecretUnchanged int
|
|
|
3aa8f6 |
- NotImported int
|
|
|
3aa8f6 |
- Imports []ImportStatus
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (c *Context) Import(keyData *Data) (*ImportResult, error) {
|
|
|
3aa8f6 |
- err := handleError(C.gpgme_op_import(c.ctx, keyData.dh))
|
|
|
3aa8f6 |
- if err != nil {
|
|
|
3aa8f6 |
- return nil, err
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- res := C.gpgme_op_import_result(c.ctx)
|
|
|
3aa8f6 |
- imports := []ImportStatus{}
|
|
|
3aa8f6 |
- for s := res.imports; s != nil; s = s.next {
|
|
|
3aa8f6 |
- imports = append(imports, ImportStatus{
|
|
|
3aa8f6 |
- Fingerprint: C.GoString(s.fpr),
|
|
|
3aa8f6 |
- Result: handleError(s.result),
|
|
|
3aa8f6 |
- Status: ImportStatusFlags(s.status),
|
|
|
3aa8f6 |
- })
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &ImportResult{
|
|
|
3aa8f6 |
- Considered: int(res.considered),
|
|
|
3aa8f6 |
- NoUserID: int(res.no_user_id),
|
|
|
3aa8f6 |
- Imported: int(res.imported),
|
|
|
3aa8f6 |
- ImportedRSA: int(res.imported_rsa),
|
|
|
3aa8f6 |
- Unchanged: int(res.unchanged),
|
|
|
3aa8f6 |
- NewUserIDs: int(res.new_user_ids),
|
|
|
3aa8f6 |
- NewSubKeys: int(res.new_sub_keys),
|
|
|
3aa8f6 |
- NewSignatures: int(res.new_signatures),
|
|
|
3aa8f6 |
- NewRevocations: int(res.new_revocations),
|
|
|
3aa8f6 |
- SecretRead: int(res.secret_read),
|
|
|
3aa8f6 |
- SecretImported: int(res.secret_imported),
|
|
|
3aa8f6 |
- SecretUnchanged: int(res.secret_unchanged),
|
|
|
3aa8f6 |
- NotImported: int(res.not_imported),
|
|
|
3aa8f6 |
- Imports: imports,
|
|
|
3aa8f6 |
- }, nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type Key struct {
|
|
|
3aa8f6 |
- k C.gpgme_key_t
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func newKey() *Key {
|
|
|
3aa8f6 |
- k := &Key{}
|
|
|
3aa8f6 |
- runtime.SetFinalizer(k, (*Key).Release)
|
|
|
3aa8f6 |
- return k
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Release() {
|
|
|
3aa8f6 |
- C.gpgme_key_release(k.k)
|
|
|
3aa8f6 |
- k.k = nil
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Revoked() bool {
|
|
|
3aa8f6 |
- return C.key_revoked(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Expired() bool {
|
|
|
3aa8f6 |
- return C.key_expired(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Disabled() bool {
|
|
|
3aa8f6 |
- return C.key_disabled(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Invalid() bool {
|
|
|
3aa8f6 |
- return C.key_invalid(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) CanEncrypt() bool {
|
|
|
3aa8f6 |
- return C.key_can_encrypt(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) CanSign() bool {
|
|
|
3aa8f6 |
- return C.key_can_sign(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) CanCertify() bool {
|
|
|
3aa8f6 |
- return C.key_can_certify(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Secret() bool {
|
|
|
3aa8f6 |
- return C.key_secret(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) CanAuthenticate() bool {
|
|
|
3aa8f6 |
- return C.key_can_authenticate(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) IsQualified() bool {
|
|
|
3aa8f6 |
- return C.key_is_qualified(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(k.k.protocol)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) IssuerSerial() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.issuer_serial)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) IssuerName() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.issuer_name)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) ChainID() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.chain_id)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) OwnerTrust() Validity {
|
|
|
3aa8f6 |
- return Validity(k.k.owner_trust)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) SubKeys() *SubKey {
|
|
|
3aa8f6 |
- if k.k.subkeys == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &SubKey{k: k.k.subkeys, parent: k}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) UserIDs() *UserID {
|
|
|
3aa8f6 |
- if k.k.uids == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &UserID{u: k.k.uids, parent: k}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *Key) KeyListMode() KeyListMode {
|
|
|
3aa8f6 |
- return KeyListMode(k.k.keylist_mode)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type SubKey struct {
|
|
|
3aa8f6 |
- k C.gpgme_subkey_t
|
|
|
3aa8f6 |
- parent *Key // make sure the key is not released when we have a reference to a subkey
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Next() *SubKey {
|
|
|
3aa8f6 |
- if k.k.next == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &SubKey{k: k.k.next, parent: k.parent}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Revoked() bool {
|
|
|
3aa8f6 |
- return C.subkey_revoked(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Expired() bool {
|
|
|
3aa8f6 |
- return C.subkey_expired(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Disabled() bool {
|
|
|
3aa8f6 |
- return C.subkey_disabled(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Invalid() bool {
|
|
|
3aa8f6 |
- return C.subkey_invalid(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Secret() bool {
|
|
|
3aa8f6 |
- return C.subkey_secret(k.k) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) KeyID() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.keyid)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Fingerprint() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.fpr)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Created() time.Time {
|
|
|
3aa8f6 |
- if k.k.timestamp <= 0 {
|
|
|
3aa8f6 |
- return time.Time{}
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return time.Unix(int64(k.k.timestamp), 0)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) Expires() time.Time {
|
|
|
3aa8f6 |
- if k.k.expires <= 0 {
|
|
|
3aa8f6 |
- return time.Time{}
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return time.Unix(int64(k.k.expires), 0)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (k *SubKey) CardNumber() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.card_number)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-type UserID struct {
|
|
|
3aa8f6 |
- u C.gpgme_user_id_t
|
|
|
3aa8f6 |
- parent *Key // make sure the key is not released when we have a reference to a user ID
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Next() *UserID {
|
|
|
3aa8f6 |
- if u.u.next == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
- }
|
|
|
3aa8f6 |
- return &UserID{u: u.u.next, parent: u.parent}
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Revoked() bool {
|
|
|
3aa8f6 |
- return C.uid_revoked(u.u) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Invalid() bool {
|
|
|
3aa8f6 |
- return C.uid_invalid(u.u) != 0
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Validity() Validity {
|
|
|
3aa8f6 |
- return Validity(u.u.validity)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) UID() string {
|
|
|
3aa8f6 |
- return C.GoString(u.u.uid)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Name() string {
|
|
|
3aa8f6 |
- return C.GoString(u.u.name)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Comment() string {
|
|
|
3aa8f6 |
- return C.GoString(u.u.comment)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-func (u *UserID) Email() string {
|
|
|
3aa8f6 |
- return C.GoString(u.u.email)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// This is somewhat of a horrible hack. We need to unset GPG_AGENT_INFO so that gpgme does not pass --use-agent to GPG.
|
|
|
3aa8f6 |
-// os.Unsetenv should be enough, but that only calls the underlying C library (which gpgme uses) if cgo is involved
|
|
|
3aa8f6 |
-// - and cgo can't be used in tests. So, provide this helper for test initialization.
|
|
|
3aa8f6 |
-func unsetenvGPGAgentInfo() {
|
|
|
3aa8f6 |
- v := C.CString("GPG_AGENT_INFO")
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(v))
|
|
|
3aa8f6 |
- C.unsetenv(v)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
From 2c7552e51215d4bf6982b0999df2d67d0bc0de9f Mon Sep 17 00:00:00 2001
|
|
|
3aa8f6 |
From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= <mitr@redhat.com>
|
|
|
3aa8f6 |
Date: Thu, 20 Feb 2020 16:41:57 +0100
|
|
|
3aa8f6 |
Subject: [PATCH 2/2] Update to github.com/mtrmac/gpgme v0.1.2
|
|
|
3aa8f6 |
MIME-Version: 1.0
|
|
|
3aa8f6 |
Content-Type: text/plain; charset=UTF-8
|
|
|
3aa8f6 |
Content-Transfer-Encoding: 8bit
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
This fixes CVE-2020-8945 by incorporating
|
|
|
3aa8f6 |
https://github.com/proglottis/gpgme/pull/23 .
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
Other changes included by the rebase:
|
|
|
3aa8f6 |
- Support for gpgme_off_t (~no-op with the RHEL 7 GPGME 1.3.2)
|
|
|
3aa8f6 |
- Wrapping a few more GPGME functions (irrelevant if we don't call them)
|
|
|
3aa8f6 |
- Better error reporting in Context.GetKey
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
Given how invasive the CVE fix is (affecting basically all binding
|
|
|
3aa8f6 |
code), it seems safer to just update the package (and be verifiably
|
|
|
3aa8f6 |
equivalent with upstream) than to backport and try to back out the few
|
|
|
3aa8f6 |
other changes.
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
Performed by updating vendor.conf, and
|
|
|
3aa8f6 |
$ mkdir -p _build/src/github.com/docker
|
|
|
3aa8f6 |
$ ln -s $(pwd) _build/src/github.com/docker/docker
|
|
|
3aa8f6 |
$ GOPATH=$(pwd)/_build:$GOPATH vndr github.com/mtrmac/gpgme
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
|
|
|
3aa8f6 |
---
|
|
|
3aa8f6 |
vendor.conf | 2 +-
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/README.md | 13 +
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/data.go | 18 +-
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/go.mod | 3 +
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/go_gpgme.c | 22 ++
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/go_gpgme.h | 12 +
|
|
|
3aa8f6 |
vendor/github.com/mtrmac/gpgme/gpgme.go | 354 ++++++++++++++----
|
|
|
3aa8f6 |
.../mtrmac/gpgme/unset_agent_info.go | 18 +
|
|
|
3aa8f6 |
.../mtrmac/gpgme/unset_agent_info_windows.go | 14 +
|
|
|
3aa8f6 |
9 files changed, 378 insertions(+), 78 deletions(-)
|
|
|
3aa8f6 |
create mode 100644 vendor/github.com/mtrmac/gpgme/README.md
|
|
|
3aa8f6 |
create mode 100644 vendor/github.com/mtrmac/gpgme/go.mod
|
|
|
3aa8f6 |
create mode 100644 vendor/github.com/mtrmac/gpgme/unset_agent_info.go
|
|
|
3aa8f6 |
create mode 100644 vendor/github.com/mtrmac/gpgme/unset_agent_info_windows.go
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
diff --git a/vendor.conf b/vendor.conf
|
|
|
3aa8f6 |
index d71bcac3ccec..4d4927b0d6f2 100644
|
|
|
3aa8f6 |
--- a/vendor.conf
|
|
|
3aa8f6 |
+++ b/vendor.conf
|
|
|
3aa8f6 |
@@ -147,7 +147,7 @@ github.com/opencontainers/image-spec v1.0.0-rc4
|
|
|
3aa8f6 |
k8s.io/kubernetes 4a3f9c5b19c7ff804cbc1bf37a15c044ca5d2353 https://github.com/openshift/kubernetes
|
|
|
3aa8f6 |
github.com/golang/glog 44145f04b68cf362d9c4df2182967c2275eaefed
|
|
|
3aa8f6 |
github.com/ghodss/yaml 73d445a93680fa1a78ae23a5839bad48f32ba1ee
|
|
|
3aa8f6 |
-github.com/mtrmac/gpgme master
|
|
|
3aa8f6 |
+github.com/mtrmac/gpgme v0.1.2
|
|
|
3aa8f6 |
github.com/containers/storage master
|
|
|
3aa8f6 |
github.com/opencontainers/go-digest master
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/README.md b/vendor/github.com/mtrmac/gpgme/README.md
|
|
|
3aa8f6 |
new file mode 100644
|
|
|
3aa8f6 |
index 000000000000..4770b82a8e61
|
|
|
3aa8f6 |
--- /dev/null
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/README.md
|
|
|
3aa8f6 |
@@ -0,0 +1,13 @@
|
|
|
3aa8f6 |
+# GPGME (golang)
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+Go wrapper for the GPGME library.
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+This library is intended for use with desktop applications. If you are looking to add OpenPGP support to a server application I suggest you first look at [golang.org/x/crypto/openpgp](https://godoc.org/golang.org/x/crypto/openpgp).
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+## Installation
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+ go get -u github.com/proglottis/gpgme
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+## Documentation
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+* [godoc](https://godoc.org/github.com/proglottis/gpgme)
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/data.go b/vendor/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
index eebc9726347d..eee32c0323fc 100644
|
|
|
3aa8f6 |
--- a/vendor/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/data.go
|
|
|
3aa8f6 |
@@ -50,25 +50,25 @@ func gogpgme_writefunc(handle, buffer unsafe.Pointer, size C.size_t) C.ssize_t {
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
//export gogpgme_seekfunc
|
|
|
3aa8f6 |
-func gogpgme_seekfunc(handle unsafe.Pointer, offset C.off_t, whence C.int) C.off_t {
|
|
|
3aa8f6 |
+func gogpgme_seekfunc(handle unsafe.Pointer, offset C.gpgme_off_t, whence C.int) C.gpgme_off_t {
|
|
|
3aa8f6 |
d := callbackLookup(uintptr(handle)).(*Data)
|
|
|
3aa8f6 |
n, err := d.s.Seek(int64(offset), int(whence))
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
C.gpgme_err_set_errno(C.EIO)
|
|
|
3aa8f6 |
return -1
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return C.off_t(n)
|
|
|
3aa8f6 |
+ return C.gpgme_off_t(n)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
// The Data buffer used to communicate with GPGME
|
|
|
3aa8f6 |
type Data struct {
|
|
|
3aa8f6 |
- dh C.gpgme_data_t
|
|
|
3aa8f6 |
+ dh C.gpgme_data_t // WARNING: Call runtime.KeepAlive(d) after ANY passing of d.dh to C
|
|
|
3aa8f6 |
buf []byte
|
|
|
3aa8f6 |
cbs C.struct_gpgme_data_cbs
|
|
|
3aa8f6 |
r io.Reader
|
|
|
3aa8f6 |
w io.Writer
|
|
|
3aa8f6 |
s io.Seeker
|
|
|
3aa8f6 |
- cbc uintptr
|
|
|
3aa8f6 |
+ cbc uintptr // WARNING: Call runtime.KeepAlive(d) after ANY use of d.cbc in C (typically via d.dh)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func newData() *Data {
|
|
|
3aa8f6 |
@@ -154,12 +154,14 @@ func (d *Data) Close() error {
|
|
|
3aa8f6 |
callbackDelete(d.cbc)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
_, err := C.gpgme_data_release(d.dh)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(d)
|
|
|
3aa8f6 |
d.dh = nil
|
|
|
3aa8f6 |
return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (d *Data) Write(p []byte) (int, error) {
|
|
|
3aa8f6 |
n, err := C.gpgme_data_write(d.dh, unsafe.Pointer(&p[0]), C.size_t(len(p)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(d)
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
return 0, err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
@@ -171,6 +173,7 @@ func (d *Data) Write(p []byte) (int, error) {
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (d *Data) Read(p []byte) (int, error) {
|
|
|
3aa8f6 |
n, err := C.gpgme_data_read(d.dh, unsafe.Pointer(&p[0]), C.size_t(len(p)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(d)
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
return 0, err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
@@ -181,11 +184,14 @@ func (d *Data) Read(p []byte) (int, error) {
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (d *Data) Seek(offset int64, whence int) (int64, error) {
|
|
|
3aa8f6 |
- n, err := C.gpgme_data_seek(d.dh, C.off_t(offset), C.int(whence))
|
|
|
3aa8f6 |
+ n, err := C.gogpgme_data_seek(d.dh, C.gpgme_off_t(offset), C.int(whence))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(d)
|
|
|
3aa8f6 |
return int64(n), err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
// Name returns the associated filename if any
|
|
|
3aa8f6 |
func (d *Data) Name() string {
|
|
|
3aa8f6 |
- return C.GoString(C.gpgme_data_get_file_name(d.dh))
|
|
|
3aa8f6 |
+ res := C.GoString(C.gpgme_data_get_file_name(d.dh))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(d)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/go.mod b/vendor/github.com/mtrmac/gpgme/go.mod
|
|
|
3aa8f6 |
new file mode 100644
|
|
|
3aa8f6 |
index 000000000000..3dd09c9fbae5
|
|
|
3aa8f6 |
--- /dev/null
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/go.mod
|
|
|
3aa8f6 |
@@ -0,0 +1,3 @@
|
|
|
3aa8f6 |
+module github.com/mtrmac/gpgme
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+go 1.11
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/go_gpgme.c b/vendor/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
index b887574e0cb9..00da3ab304f1 100644
|
|
|
3aa8f6 |
--- a/vendor/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/go_gpgme.c
|
|
|
3aa8f6 |
@@ -8,6 +8,28 @@ void gogpgme_set_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, uintpt
|
|
|
3aa8f6 |
gpgme_set_passphrase_cb(ctx, cb, (void *)handle);
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
+gpgme_off_t gogpgme_data_seek(gpgme_data_t dh, gpgme_off_t offset, int whence) {
|
|
|
3aa8f6 |
+ return gpgme_data_seek(dh, offset, whence);
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+gpgme_error_t gogpgme_op_assuan_transact_ext(
|
|
|
3aa8f6 |
+ gpgme_ctx_t ctx,
|
|
|
3aa8f6 |
+ char* cmd,
|
|
|
3aa8f6 |
+ uintptr_t data_h,
|
|
|
3aa8f6 |
+ uintptr_t inquiry_h,
|
|
|
3aa8f6 |
+ uintptr_t status_h,
|
|
|
3aa8f6 |
+ gpgme_error_t *operr
|
|
|
3aa8f6 |
+ ){
|
|
|
3aa8f6 |
+ return gpgme_op_assuan_transact_ext(
|
|
|
3aa8f6 |
+ ctx,
|
|
|
3aa8f6 |
+ cmd,
|
|
|
3aa8f6 |
+ (gpgme_assuan_data_cb_t) gogpgme_assuan_data_callback, (void *)data_h,
|
|
|
3aa8f6 |
+ (gpgme_assuan_inquire_cb_t) gogpgme_assuan_inquiry_callback, (void *)inquiry_h,
|
|
|
3aa8f6 |
+ (gpgme_assuan_status_cb_t) gogpgme_assuan_status_callback, (void *)status_h,
|
|
|
3aa8f6 |
+ operr
|
|
|
3aa8f6 |
+ );
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
unsigned int key_revoked(gpgme_key_t k) {
|
|
|
3aa8f6 |
return k->revoked;
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/go_gpgme.h b/vendor/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
index a3678b127ac7..d4826ab368eb 100644
|
|
|
3aa8f6 |
--- a/vendor/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/go_gpgme.h
|
|
|
3aa8f6 |
@@ -6,12 +6,24 @@
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
#include <gpgme.h>
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
+/* GPGME_VERSION_NUMBER was introduced in 1.4.0 */
|
|
|
3aa8f6 |
+#if !defined(GPGME_VERSION_NUMBER) || GPGME_VERSION_NUMBER < 0x010402
|
|
|
3aa8f6 |
+typedef off_t gpgme_off_t; /* Introduced in 1.4.2 */
|
|
|
3aa8f6 |
+#endif
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
extern ssize_t gogpgme_readfunc(void *handle, void *buffer, size_t size);
|
|
|
3aa8f6 |
extern ssize_t gogpgme_writefunc(void *handle, void *buffer, size_t size);
|
|
|
3aa8f6 |
extern off_t gogpgme_seekfunc(void *handle, off_t offset, int whence);
|
|
|
3aa8f6 |
extern gpgme_error_t gogpgme_passfunc(void *hook, char *uid_hint, char *passphrase_info, int prev_was_bad, int fd);
|
|
|
3aa8f6 |
extern gpgme_error_t gogpgme_data_new_from_cbs(gpgme_data_t *dh, gpgme_data_cbs_t cbs, uintptr_t handle);
|
|
|
3aa8f6 |
extern void gogpgme_set_passphrase_cb(gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, uintptr_t handle);
|
|
|
3aa8f6 |
+extern gpgme_off_t gogpgme_data_seek(gpgme_data_t dh, gpgme_off_t offset, int whence);
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+extern gpgme_error_t gogpgme_op_assuan_transact_ext(gpgme_ctx_t ctx, char *cmd, uintptr_t data_h, uintptr_t inquiry_h , uintptr_t status_h, gpgme_error_t *operr);
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+extern gpgme_error_t gogpgme_assuan_data_callback(void *opaque, void* data, size_t datalen );
|
|
|
3aa8f6 |
+extern gpgme_error_t gogpgme_assuan_inquiry_callback(void *opaque, char* name, char* args);
|
|
|
3aa8f6 |
+extern gpgme_error_t gogpgme_assuan_status_callback(void *opaque, char* status, char* args);
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
extern unsigned int key_revoked(gpgme_key_t k);
|
|
|
3aa8f6 |
extern unsigned int key_expired(gpgme_key_t k);
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/gpgme.go b/vendor/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
index 5f1793eab32d..c19b9aebc5cd 100644
|
|
|
3aa8f6 |
--- a/vendor/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/gpgme.go
|
|
|
3aa8f6 |
@@ -7,8 +7,8 @@ package gpgme
|
|
|
3aa8f6 |
// #include <gpgme.h>
|
|
|
3aa8f6 |
// #include "go_gpgme.h"
|
|
|
3aa8f6 |
import "C"
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
import (
|
|
|
3aa8f6 |
+ "fmt"
|
|
|
3aa8f6 |
"io"
|
|
|
3aa8f6 |
"os"
|
|
|
3aa8f6 |
"runtime"
|
|
|
3aa8f6 |
@@ -47,9 +47,8 @@ const (
|
|
|
3aa8f6 |
ProtocolAssuan Protocol = C.GPGME_PROTOCOL_ASSUAN
|
|
|
3aa8f6 |
ProtocolG13 Protocol = C.GPGME_PROTOCOL_G13
|
|
|
3aa8f6 |
ProtocolUIServer Protocol = C.GPGME_PROTOCOL_UISERVER
|
|
|
3aa8f6 |
- // ProtocolSpawn Protocol = C.GPGME_PROTOCOL_SPAWN // Unavailable in 1.4.3
|
|
|
3aa8f6 |
- ProtocolDefault Protocol = C.GPGME_PROTOCOL_DEFAULT
|
|
|
3aa8f6 |
- ProtocolUnknown Protocol = C.GPGME_PROTOCOL_UNKNOWN
|
|
|
3aa8f6 |
+ ProtocolDefault Protocol = C.GPGME_PROTOCOL_DEFAULT
|
|
|
3aa8f6 |
+ ProtocolUnknown Protocol = C.GPGME_PROTOCOL_UNKNOWN
|
|
|
3aa8f6 |
)
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type PinEntryMode int
|
|
|
3aa8f6 |
@@ -69,7 +68,6 @@ const (
|
|
|
3aa8f6 |
EncryptNoEncryptTo EncryptFlag = C.GPGME_ENCRYPT_NO_ENCRYPT_TO
|
|
|
3aa8f6 |
EncryptPrepare EncryptFlag = C.GPGME_ENCRYPT_PREPARE
|
|
|
3aa8f6 |
EncryptExceptSign EncryptFlag = C.GPGME_ENCRYPT_EXPECT_SIGN
|
|
|
3aa8f6 |
- // EncryptNoCompress EncryptFlag = C.GPGME_ENCRYPT_NO_COMPRESS // Unavailable in 1.4.3
|
|
|
3aa8f6 |
)
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type HashAlgo int
|
|
|
3aa8f6 |
@@ -83,7 +81,6 @@ const (
|
|
|
3aa8f6 |
KeyListModeExtern KeyListMode = C.GPGME_KEYLIST_MODE_EXTERN
|
|
|
3aa8f6 |
KeyListModeSigs KeyListMode = C.GPGME_KEYLIST_MODE_SIGS
|
|
|
3aa8f6 |
KeyListModeSigNotations KeyListMode = C.GPGME_KEYLIST_MODE_SIG_NOTATIONS
|
|
|
3aa8f6 |
- // KeyListModeWithSecret KeyListMode = C.GPGME_KEYLIST_MODE_WITH_SECRET // Unavailable in 1.4.3
|
|
|
3aa8f6 |
KeyListModeEphemeral KeyListMode = C.GPGME_KEYLIST_MODE_EPHEMERAL
|
|
|
3aa8f6 |
KeyListModeModeValidate KeyListMode = C.GPGME_KEYLIST_MODE_VALIDATE
|
|
|
3aa8f6 |
)
|
|
|
3aa8f6 |
@@ -167,39 +164,60 @@ func EngineCheckVersion(p Protocol) error {
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type EngineInfo struct {
|
|
|
3aa8f6 |
- info C.gpgme_engine_info_t
|
|
|
3aa8f6 |
+ next *EngineInfo
|
|
|
3aa8f6 |
+ protocol Protocol
|
|
|
3aa8f6 |
+ fileName string
|
|
|
3aa8f6 |
+ homeDir string
|
|
|
3aa8f6 |
+ version string
|
|
|
3aa8f6 |
+ requiredVersion string
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
-func (e *EngineInfo) Next() *EngineInfo {
|
|
|
3aa8f6 |
- if e.info.next == nil {
|
|
|
3aa8f6 |
- return nil
|
|
|
3aa8f6 |
+func copyEngineInfo(info C.gpgme_engine_info_t) *EngineInfo {
|
|
|
3aa8f6 |
+ res := &EngineInfo{
|
|
|
3aa8f6 |
+ next: nil,
|
|
|
3aa8f6 |
+ protocol: Protocol(info.protocol),
|
|
|
3aa8f6 |
+ fileName: C.GoString(info.file_name),
|
|
|
3aa8f6 |
+ homeDir: C.GoString(info.home_dir),
|
|
|
3aa8f6 |
+ version: C.GoString(info.version),
|
|
|
3aa8f6 |
+ requiredVersion: C.GoString(info.req_version),
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ if info.next != nil {
|
|
|
3aa8f6 |
+ res.next = copyEngineInfo(info.next)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return &EngineInfo{info: e.info.next}
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+func (e *EngineInfo) Next() *EngineInfo {
|
|
|
3aa8f6 |
+ return e.next
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (e *EngineInfo) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(e.info.protocol)
|
|
|
3aa8f6 |
+ return e.protocol
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (e *EngineInfo) FileName() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.file_name)
|
|
|
3aa8f6 |
+ return e.fileName
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (e *EngineInfo) Version() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.version)
|
|
|
3aa8f6 |
+ return e.version
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (e *EngineInfo) RequiredVersion() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.req_version)
|
|
|
3aa8f6 |
+ return e.requiredVersion
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (e *EngineInfo) HomeDir() string {
|
|
|
3aa8f6 |
- return C.GoString(e.info.home_dir)
|
|
|
3aa8f6 |
+ return e.homeDir
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func GetEngineInfo() (*EngineInfo, error) {
|
|
|
3aa8f6 |
- info := &EngineInfo{}
|
|
|
3aa8f6 |
- return info, handleError(C.gpgme_get_engine_info(&info.info))
|
|
|
3aa8f6 |
+ var cInfo C.gpgme_engine_info_t
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_get_engine_info(&cInfo))
|
|
|
3aa8f6 |
+ if err != nil {
|
|
|
3aa8f6 |
+ return nil, err
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ return copyEngineInfo(cInfo), nil // It is up to the caller not to invalidate cInfo concurrently until this is done.
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func SetEngineInfo(proto Protocol, fileName, homeDir string) error {
|
|
|
3aa8f6 |
@@ -260,9 +278,9 @@ type Context struct {
|
|
|
3aa8f6 |
KeyError error
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
callback Callback
|
|
|
3aa8f6 |
- cbc uintptr
|
|
|
3aa8f6 |
+ cbc uintptr // WARNING: Call runtime.KeepAlive(c) after ANY use of c.cbc in C (typically via c.ctx)
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
- ctx C.gpgme_ctx_t
|
|
|
3aa8f6 |
+ ctx C.gpgme_ctx_t // WARNING: Call runtime.KeepAlive(c) after ANY passing of c.ctx to C
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func New() (*Context, error) {
|
|
|
3aa8f6 |
@@ -280,49 +298,68 @@ func (c *Context) Release() {
|
|
|
3aa8f6 |
callbackDelete(c.cbc)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
C.gpgme_release(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
c.ctx = nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetArmor(yes bool) {
|
|
|
3aa8f6 |
C.gpgme_set_armor(c.ctx, cbool(yes))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Armor() bool {
|
|
|
3aa8f6 |
- return C.gpgme_get_armor(c.ctx) != 0
|
|
|
3aa8f6 |
+ res := C.gpgme_get_armor(c.ctx) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetTextMode(yes bool) {
|
|
|
3aa8f6 |
C.gpgme_set_textmode(c.ctx, cbool(yes))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) TextMode() bool {
|
|
|
3aa8f6 |
- return C.gpgme_get_textmode(c.ctx) != 0
|
|
|
3aa8f6 |
+ res := C.gpgme_get_textmode(c.ctx) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetProtocol(p Protocol) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_set_protocol(c.ctx, C.gpgme_protocol_t(p)))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_set_protocol(c.ctx, C.gpgme_protocol_t(p)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(C.gpgme_get_protocol(c.ctx))
|
|
|
3aa8f6 |
+ res := Protocol(C.gpgme_get_protocol(c.ctx))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetKeyListMode(m KeyListMode) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_set_keylist_mode(c.ctx, C.gpgme_keylist_mode_t(m)))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_set_keylist_mode(c.ctx, C.gpgme_keylist_mode_t(m)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) KeyListMode() KeyListMode {
|
|
|
3aa8f6 |
- return KeyListMode(C.gpgme_get_keylist_mode(c.ctx))
|
|
|
3aa8f6 |
+ res := KeyListMode(C.gpgme_get_keylist_mode(c.ctx))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
// Unavailable in 1.3.2:
|
|
|
3aa8f6 |
// func (c *Context) SetPinEntryMode(m PinEntryMode) error {
|
|
|
3aa8f6 |
-// return handleError(C.gpgme_set_pinentry_mode(c.ctx, C.gpgme_pinentry_mode_t(m)))
|
|
|
3aa8f6 |
+// err := handleError(C.gpgme_set_pinentry_mode(c.ctx, C.gpgme_pinentry_mode_t(m)))
|
|
|
3aa8f6 |
+// runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+// return err
|
|
|
3aa8f6 |
// }
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
// Unavailable in 1.3.2:
|
|
|
3aa8f6 |
// func (c *Context) PinEntryMode() PinEntryMode {
|
|
|
3aa8f6 |
-// return PinEntryMode(C.gpgme_get_pinentry_mode(c.ctx))
|
|
|
3aa8f6 |
+// res := PinEntryMode(C.gpgme_get_pinentry_mode(c.ctx))
|
|
|
3aa8f6 |
+// runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+// return res
|
|
|
3aa8f6 |
// }
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetCallback(callback Callback) error {
|
|
|
3aa8f6 |
@@ -339,11 +376,17 @@ func (c *Context) SetCallback(callback Callback) error {
|
|
|
3aa8f6 |
c.cbc = 0
|
|
|
3aa8f6 |
_, err = C.gogpgme_set_passphrase_cb(c.ctx, nil, 0)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) EngineInfo() *EngineInfo {
|
|
|
3aa8f6 |
- return &EngineInfo{info: C.gpgme_ctx_get_engine_info(c.ctx)}
|
|
|
3aa8f6 |
+ cInfo := C.gpgme_ctx_get_engine_info(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ // NOTE: c must be live as long as we are accessing cInfo.
|
|
|
3aa8f6 |
+ res := copyEngineInfo(cInfo)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c) // for accesses to cInfo
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) SetEngineInfo(proto Protocol, fileName, homeDir string) error {
|
|
|
3aa8f6 |
@@ -356,19 +399,23 @@ func (c *Context) SetEngineInfo(proto Protocol, fileName, homeDir string) error
|
|
|
3aa8f6 |
chome = C.CString(homeDir)
|
|
|
3aa8f6 |
defer C.free(unsafe.Pointer(chome))
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return handleError(C.gpgme_ctx_set_engine_info(c.ctx, C.gpgme_protocol_t(proto), cfn, chome))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_ctx_set_engine_info(c.ctx, C.gpgme_protocol_t(proto), cfn, chome))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) KeyListStart(pattern string, secretOnly bool) error {
|
|
|
3aa8f6 |
cpattern := C.CString(pattern)
|
|
|
3aa8f6 |
defer C.free(unsafe.Pointer(cpattern))
|
|
|
3aa8f6 |
- err := C.gpgme_op_keylist_start(c.ctx, cpattern, cbool(secretOnly))
|
|
|
3aa8f6 |
- return handleError(err)
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_keylist_start(c.ctx, cpattern, cbool(secretOnly)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) KeyListNext() bool {
|
|
|
3aa8f6 |
c.Key = newKey()
|
|
|
3aa8f6 |
err := handleError(C.gpgme_op_keylist_next(c.ctx, &c.Key.k))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c) // implies runtime.KeepAlive(c.Key)
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
if e, ok := err.(Error); ok && e.Code() == ErrorEOF {
|
|
|
3aa8f6 |
c.KeyError = nil
|
|
|
3aa8f6 |
@@ -382,22 +429,43 @@ func (c *Context) KeyListNext() bool {
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) KeyListEnd() error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_keylist_end(c.ctx))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_keylist_end(c.ctx))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) GetKey(fingerprint string, secret bool) (*Key, error) {
|
|
|
3aa8f6 |
key := newKey()
|
|
|
3aa8f6 |
cfpr := C.CString(fingerprint)
|
|
|
3aa8f6 |
defer C.free(unsafe.Pointer(cfpr))
|
|
|
3aa8f6 |
- return key, handleError(C.gpgme_get_key(c.ctx, cfpr, &key.k, cbool(secret)))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_get_key(c.ctx, cfpr, &key.k, cbool(secret)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(key)
|
|
|
3aa8f6 |
+ keyKIsNil := key.k == nil
|
|
|
3aa8f6 |
+ runtime.KeepAlive(key)
|
|
|
3aa8f6 |
+ if e, ok := err.(Error); keyKIsNil && ok && e.Code() == ErrorEOF {
|
|
|
3aa8f6 |
+ return nil, fmt.Errorf("key %q not found", fingerprint)
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ if err != nil {
|
|
|
3aa8f6 |
+ return nil, err
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ return key, nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Decrypt(ciphertext, plaintext *Data) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_decrypt(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_decrypt(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(ciphertext)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(plaintext)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) DecryptVerify(ciphertext, plaintext *Data) error {
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_decrypt_verify(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_decrypt_verify(c.ctx, ciphertext.dh, plaintext.dh))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(ciphertext)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(plaintext)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type Signature struct {
|
|
|
3aa8f6 |
@@ -424,10 +492,20 @@ func (c *Context) Verify(sig, signedText, plain *Data) (string, []Signature, err
|
|
|
3aa8f6 |
plainPtr = plain.dh
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
err := handleError(C.gpgme_op_verify(c.ctx, sig.dh, signedTextPtr, plainPtr))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(sig)
|
|
|
3aa8f6 |
+ if signedText != nil {
|
|
|
3aa8f6 |
+ runtime.KeepAlive(signedText)
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ if plain != nil {
|
|
|
3aa8f6 |
+ runtime.KeepAlive(plain)
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
return "", nil, err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
res := C.gpgme_op_verify_result(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ // NOTE: c must be live as long as we are accessing res.
|
|
|
3aa8f6 |
sigs := []Signature{}
|
|
|
3aa8f6 |
for s := res.signatures; s != nil; s = s.next {
|
|
|
3aa8f6 |
sig := Signature{
|
|
|
3aa8f6 |
@@ -447,7 +525,9 @@ func (c *Context) Verify(sig, signedText, plain *Data) (string, []Signature, err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
sigs = append(sigs, sig)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return C.GoString(res.file_name), sigs, nil
|
|
|
3aa8f6 |
+ fileName := C.GoString(res.file_name)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c) // for all accesses to res above
|
|
|
3aa8f6 |
+ return fileName, sigs, nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Encrypt(recipients []*Key, flags EncryptFlag, plaintext, ciphertext *Data) error {
|
|
|
3aa8f6 |
@@ -459,18 +539,116 @@ func (c *Context) Encrypt(recipients []*Key, flags EncryptFlag, plaintext, ciphe
|
|
|
3aa8f6 |
*ptr = recipients[i].k
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
err := C.gpgme_op_encrypt(c.ctx, (*C.gpgme_key_t)(recp), C.gpgme_encrypt_flags_t(flags), plaintext.dh, ciphertext.dh)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(recipients)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(plaintext)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(ciphertext)
|
|
|
3aa8f6 |
return handleError(err)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Sign(signers []*Key, plain, sig *Data, mode SigMode) error {
|
|
|
3aa8f6 |
C.gpgme_signers_clear(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
for _, k := range signers {
|
|
|
3aa8f6 |
- if err := handleError(C.gpgme_signers_add(c.ctx, k.k)); err != nil {
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_signers_add(c.ctx, k.k))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ if err != nil {
|
|
|
3aa8f6 |
C.gpgme_signers_clear(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return handleError(C.gpgme_op_sign(c.ctx, plain.dh, sig.dh, C.gpgme_sig_mode_t(mode)))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_sign(c.ctx, plain.dh, sig.dh, C.gpgme_sig_mode_t(mode)))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(plain)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(sig)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+type AssuanDataCallback func(data []byte) error
|
|
|
3aa8f6 |
+type AssuanInquireCallback func(name, args string) error
|
|
|
3aa8f6 |
+type AssuanStatusCallback func(status, args string) error
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// AssuanSend sends a raw Assuan command to gpg-agent
|
|
|
3aa8f6 |
+func (c *Context) AssuanSend(
|
|
|
3aa8f6 |
+ cmd string,
|
|
|
3aa8f6 |
+ data AssuanDataCallback,
|
|
|
3aa8f6 |
+ inquiry AssuanInquireCallback,
|
|
|
3aa8f6 |
+ status AssuanStatusCallback,
|
|
|
3aa8f6 |
+) error {
|
|
|
3aa8f6 |
+ var operr C.gpgme_error_t
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+ dataPtr := callbackAdd(&data)
|
|
|
3aa8f6 |
+ inquiryPtr := callbackAdd(&inquiry)
|
|
|
3aa8f6 |
+ statusPtr := callbackAdd(&status)
|
|
|
3aa8f6 |
+ cmdCStr := C.CString(cmd)
|
|
|
3aa8f6 |
+ defer C.free(unsafe.Pointer(cmdCStr))
|
|
|
3aa8f6 |
+ err := C.gogpgme_op_assuan_transact_ext(
|
|
|
3aa8f6 |
+ c.ctx,
|
|
|
3aa8f6 |
+ cmdCStr,
|
|
|
3aa8f6 |
+ C.uintptr_t(dataPtr),
|
|
|
3aa8f6 |
+ C.uintptr_t(inquiryPtr),
|
|
|
3aa8f6 |
+ C.uintptr_t(statusPtr),
|
|
|
3aa8f6 |
+ &operr,
|
|
|
3aa8f6 |
+ )
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+ if handleError(operr) != nil {
|
|
|
3aa8f6 |
+ return handleError(operr)
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ return handleError(err)
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+//export gogpgme_assuan_data_callback
|
|
|
3aa8f6 |
+func gogpgme_assuan_data_callback(handle unsafe.Pointer, data unsafe.Pointer, datalen C.size_t) C.gpgme_error_t {
|
|
|
3aa8f6 |
+ c := callbackLookup(uintptr(handle)).(*AssuanDataCallback)
|
|
|
3aa8f6 |
+ if *c == nil {
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ (*c)(C.GoBytes(data, C.int(datalen)))
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+//export gogpgme_assuan_inquiry_callback
|
|
|
3aa8f6 |
+func gogpgme_assuan_inquiry_callback(handle unsafe.Pointer, cName *C.char, cArgs *C.char) C.gpgme_error_t {
|
|
|
3aa8f6 |
+ name := C.GoString(cName)
|
|
|
3aa8f6 |
+ args := C.GoString(cArgs)
|
|
|
3aa8f6 |
+ c := callbackLookup(uintptr(handle)).(*AssuanInquireCallback)
|
|
|
3aa8f6 |
+ if *c == nil {
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ (*c)(name, args)
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+//export gogpgme_assuan_status_callback
|
|
|
3aa8f6 |
+func gogpgme_assuan_status_callback(handle unsafe.Pointer, cStatus *C.char, cArgs *C.char) C.gpgme_error_t {
|
|
|
3aa8f6 |
+ status := C.GoString(cStatus)
|
|
|
3aa8f6 |
+ args := C.GoString(cArgs)
|
|
|
3aa8f6 |
+ c := callbackLookup(uintptr(handle)).(*AssuanStatusCallback)
|
|
|
3aa8f6 |
+ if *c == nil {
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ (*c)(status, args)
|
|
|
3aa8f6 |
+ return 0
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// ExportModeFlags defines how keys are exported from Export
|
|
|
3aa8f6 |
+type ExportModeFlags uint
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+const (
|
|
|
3aa8f6 |
+ ExportModeExtern ExportModeFlags = C.GPGME_EXPORT_MODE_EXTERN
|
|
|
3aa8f6 |
+ ExportModeMinimal ExportModeFlags = C.GPGME_EXPORT_MODE_MINIMAL
|
|
|
3aa8f6 |
+)
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+func (c *Context) Export(pattern string, mode ExportModeFlags, data *Data) error {
|
|
|
3aa8f6 |
+ pat := C.CString(pattern)
|
|
|
3aa8f6 |
+ defer C.free(unsafe.Pointer(pat))
|
|
|
3aa8f6 |
+ err := handleError(C.gpgme_op_export(c.ctx, pat, C.gpgme_export_mode_t(mode), data.dh))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(data)
|
|
|
3aa8f6 |
+ return err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
// ImportStatusFlags describes the type of ImportStatus.Status. The C API in gpgme.h simply uses "unsigned".
|
|
|
3aa8f6 |
@@ -509,10 +687,14 @@ type ImportResult struct {
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (c *Context) Import(keyData *Data) (*ImportResult, error) {
|
|
|
3aa8f6 |
err := handleError(C.gpgme_op_import(c.ctx, keyData.dh))
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(keyData)
|
|
|
3aa8f6 |
if err != nil {
|
|
|
3aa8f6 |
return nil, err
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
res := C.gpgme_op_import_result(c.ctx)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c)
|
|
|
3aa8f6 |
+ // NOTE: c must be live as long as we are accessing res.
|
|
|
3aa8f6 |
imports := []ImportStatus{}
|
|
|
3aa8f6 |
for s := res.imports; s != nil; s = s.next {
|
|
|
3aa8f6 |
imports = append(imports, ImportStatus{
|
|
|
3aa8f6 |
@@ -521,7 +703,7 @@ func (c *Context) Import(keyData *Data) (*ImportResult, error) {
|
|
|
3aa8f6 |
Status: ImportStatusFlags(s.status),
|
|
|
3aa8f6 |
})
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return &ImportResult{
|
|
|
3aa8f6 |
+ importResult := &ImportResult{
|
|
|
3aa8f6 |
Considered: int(res.considered),
|
|
|
3aa8f6 |
NoUserID: int(res.no_user_id),
|
|
|
3aa8f6 |
Imported: int(res.imported),
|
|
|
3aa8f6 |
@@ -536,11 +718,13 @@ func (c *Context) Import(keyData *Data) (*ImportResult, error) {
|
|
|
3aa8f6 |
SecretUnchanged: int(res.secret_unchanged),
|
|
|
3aa8f6 |
NotImported: int(res.not_imported),
|
|
|
3aa8f6 |
Imports: imports,
|
|
|
3aa8f6 |
- }, nil
|
|
|
3aa8f6 |
+ }
|
|
|
3aa8f6 |
+ runtime.KeepAlive(c) // for all accesses to res above
|
|
|
3aa8f6 |
+ return importResult, nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type Key struct {
|
|
|
3aa8f6 |
- k C.gpgme_key_t
|
|
|
3aa8f6 |
+ k C.gpgme_key_t // WARNING: Call Runtime.KeepAlive(k) after ANY passing of k.k to C
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func newKey() *Key {
|
|
|
3aa8f6 |
@@ -551,85 +735,122 @@ func newKey() *Key {
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Release() {
|
|
|
3aa8f6 |
C.gpgme_key_release(k.k)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
k.k = nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Revoked() bool {
|
|
|
3aa8f6 |
- return C.key_revoked(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_revoked(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Expired() bool {
|
|
|
3aa8f6 |
- return C.key_expired(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_expired(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Disabled() bool {
|
|
|
3aa8f6 |
- return C.key_disabled(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_disabled(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Invalid() bool {
|
|
|
3aa8f6 |
- return C.key_invalid(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_invalid(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) CanEncrypt() bool {
|
|
|
3aa8f6 |
- return C.key_can_encrypt(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_can_encrypt(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) CanSign() bool {
|
|
|
3aa8f6 |
- return C.key_can_sign(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_can_sign(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) CanCertify() bool {
|
|
|
3aa8f6 |
- return C.key_can_certify(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_can_certify(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Secret() bool {
|
|
|
3aa8f6 |
- return C.key_secret(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_secret(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) CanAuthenticate() bool {
|
|
|
3aa8f6 |
- return C.key_can_authenticate(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_can_authenticate(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) IsQualified() bool {
|
|
|
3aa8f6 |
- return C.key_is_qualified(k.k) != 0
|
|
|
3aa8f6 |
+ res := C.key_is_qualified(k.k) != 0
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) Protocol() Protocol {
|
|
|
3aa8f6 |
- return Protocol(k.k.protocol)
|
|
|
3aa8f6 |
+ res := Protocol(k.k.protocol)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) IssuerSerial() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.issuer_serial)
|
|
|
3aa8f6 |
+ res := C.GoString(k.k.issuer_serial)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) IssuerName() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.issuer_name)
|
|
|
3aa8f6 |
+ res := C.GoString(k.k.issuer_name)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) ChainID() string {
|
|
|
3aa8f6 |
- return C.GoString(k.k.chain_id)
|
|
|
3aa8f6 |
+ res := C.GoString(k.k.chain_id)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) OwnerTrust() Validity {
|
|
|
3aa8f6 |
- return Validity(k.k.owner_trust)
|
|
|
3aa8f6 |
+ res := Validity(k.k.owner_trust)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) SubKeys() *SubKey {
|
|
|
3aa8f6 |
- if k.k.subkeys == nil {
|
|
|
3aa8f6 |
+ subKeys := k.k.subkeys
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ if subKeys == nil {
|
|
|
3aa8f6 |
return nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return &SubKey{k: k.k.subkeys, parent: k}
|
|
|
3aa8f6 |
+ return &SubKey{k: subKeys, parent: k} // The parent: k reference ensures subKeys remains valid
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) UserIDs() *UserID {
|
|
|
3aa8f6 |
- if k.k.uids == nil {
|
|
|
3aa8f6 |
+ uids := k.k.uids
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ if uids == nil {
|
|
|
3aa8f6 |
return nil
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
- return &UserID{u: k.k.uids, parent: k}
|
|
|
3aa8f6 |
+ return &UserID{u: uids, parent: k} // The parent: k reference ensures uids remains valid
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
func (k *Key) KeyListMode() KeyListMode {
|
|
|
3aa8f6 |
- return KeyListMode(k.k.keylist_mode)
|
|
|
3aa8f6 |
+ res := KeyListMode(k.k.keylist_mode)
|
|
|
3aa8f6 |
+ runtime.KeepAlive(k)
|
|
|
3aa8f6 |
+ return res
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
|
|
|
3aa8f6 |
type SubKey struct {
|
|
|
3aa8f6 |
@@ -729,12 +950,3 @@ func (u *UserID) Comment() string {
|
|
|
3aa8f6 |
func (u *UserID) Email() string {
|
|
|
3aa8f6 |
return C.GoString(u.u.email)
|
|
|
3aa8f6 |
}
|
|
|
3aa8f6 |
-
|
|
|
3aa8f6 |
-// This is somewhat of a horrible hack. We need to unset GPG_AGENT_INFO so that gpgme does not pass --use-agent to GPG.
|
|
|
3aa8f6 |
-// os.Unsetenv should be enough, but that only calls the underlying C library (which gpgme uses) if cgo is involved
|
|
|
3aa8f6 |
-// - and cgo can't be used in tests. So, provide this helper for test initialization.
|
|
|
3aa8f6 |
-func unsetenvGPGAgentInfo() {
|
|
|
3aa8f6 |
- v := C.CString("GPG_AGENT_INFO")
|
|
|
3aa8f6 |
- defer C.free(unsafe.Pointer(v))
|
|
|
3aa8f6 |
- C.unsetenv(v)
|
|
|
3aa8f6 |
-}
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/unset_agent_info.go b/vendor/github.com/mtrmac/gpgme/unset_agent_info.go
|
|
|
3aa8f6 |
new file mode 100644
|
|
|
3aa8f6 |
index 000000000000..986aca59f67b
|
|
|
3aa8f6 |
--- /dev/null
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/unset_agent_info.go
|
|
|
3aa8f6 |
@@ -0,0 +1,18 @@
|
|
|
3aa8f6 |
+// +build !windows
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+package gpgme
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// #include <stdlib.h>
|
|
|
3aa8f6 |
+import "C"
|
|
|
3aa8f6 |
+import (
|
|
|
3aa8f6 |
+ "unsafe"
|
|
|
3aa8f6 |
+)
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// This is somewhat of a horrible hack. We need to unset GPG_AGENT_INFO so that gpgme does not pass --use-agent to GPG.
|
|
|
3aa8f6 |
+// os.Unsetenv should be enough, but that only calls the underlying C library (which gpgme uses) if cgo is involved
|
|
|
3aa8f6 |
+// - and cgo can't be used in tests. So, provide this helper for test initialization.
|
|
|
3aa8f6 |
+func unsetenvGPGAgentInfo() {
|
|
|
3aa8f6 |
+ v := C.CString("GPG_AGENT_INFO")
|
|
|
3aa8f6 |
+ defer C.free(unsafe.Pointer(v))
|
|
|
3aa8f6 |
+ C.unsetenv(v)
|
|
|
3aa8f6 |
+}
|
|
|
3aa8f6 |
diff --git a/vendor/github.com/mtrmac/gpgme/unset_agent_info_windows.go b/vendor/github.com/mtrmac/gpgme/unset_agent_info_windows.go
|
|
|
3aa8f6 |
new file mode 100644
|
|
|
3aa8f6 |
index 000000000000..431ec86d3c24
|
|
|
3aa8f6 |
--- /dev/null
|
|
|
3aa8f6 |
+++ b/vendor/github.com/mtrmac/gpgme/unset_agent_info_windows.go
|
|
|
3aa8f6 |
@@ -0,0 +1,14 @@
|
|
|
3aa8f6 |
+package gpgme
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// #include <stdlib.h>
|
|
|
3aa8f6 |
+import "C"
|
|
|
3aa8f6 |
+import (
|
|
|
3aa8f6 |
+ "unsafe"
|
|
|
3aa8f6 |
+)
|
|
|
3aa8f6 |
+
|
|
|
3aa8f6 |
+// unsetenv is not available in mingw
|
|
|
3aa8f6 |
+func unsetenvGPGAgentInfo() {
|
|
|
3aa8f6 |
+ v := C.CString("GPG_AGENT_INFO=")
|
|
|
3aa8f6 |
+ defer C.free(unsafe.Pointer(v))
|
|
|
3aa8f6 |
+ C.putenv(v)
|
|
|
3aa8f6 |
+}
|