Lock global gopenpgp fields

This commit is contained in:
Carlos Quintana 2021-10-18 11:33:02 +02:00 committed by Carlos Quintana
parent d1b2846135
commit 9f25490f61
No known key found for this signature in database
GPG key ID: 68324E212E167F8E
3 changed files with 24 additions and 1 deletions

View file

@ -1,14 +1,21 @@
// Package crypto provides a high-level API for common OpenPGP functionality.
package crypto
import "sync"
// GopenPGP is used as a "namespace" for many of the functions in this package.
// It is a struct that keeps track of time skew between server and client.
type GopenPGP struct {
latestServerTime int64
generationOffset int64
lock *sync.Mutex
}
var pgp = GopenPGP{}
var pgp = GopenPGP{
latestServerTime: 0,
generationOffset: 0,
lock: &sync.Mutex{},
}
// clone returns a clone of the byte slice. Internal function used to make sure
// we don't retain a reference to external data.