Implement command type handling

This commit changes the wire protocol to split between command
announcement and command payload to allow proper typing of sent and
received msgpack messages.

CRL fetching has been implemented as second command after the existing
health check command.
main
Jan Dittberner 1 year ago
parent 472091b374
commit 2de592d30c

9
.gitignore vendored

@ -1,10 +1,11 @@
*.crt
*.pem
*.pub
.idea/
/.idea/
/ca-hierarchy.json
/clientsim
/config.yaml
/dist/
/repos/
/signer
/testPty
ca-hierarchy.json
config.yaml
dist/

@ -20,6 +20,7 @@ limitations under the License.
package main
import (
"bytes"
"context"
"fmt"
"os"
@ -30,6 +31,8 @@ import (
"github.com/shamaton/msgpackgen/msgpack"
"github.com/sirupsen/logrus"
"git.cacert.org/cacert-gosigner/pkg/protocol"
"git.cacert.org/cacert-gosigner/pkg/messages"
)
@ -39,7 +42,7 @@ var cobsConfig = cobs.Config{SpecialByte: cobsDelimiter, Delimiter: true, Ending
func main() {
logger := logrus.New()
logger.SetOutput(os.Stdout)
logger.SetOutput(os.Stderr)
logger.SetLevel(logrus.InfoLevel)
sim := &clientSimulator{
@ -48,14 +51,14 @@ func main() {
err := sim.Run()
if err != nil {
logger.Errorf("simulator returned an error: %v", err)
logger.WithError(err).Error("simulator returned an error")
}
}
type clientSimulator struct {
logger *logrus.Logger
commands chan messages.Command
responses chan []byte
commands chan *protocol.Command
responses chan [][]byte
}
func (c *clientSimulator) writeTestCommands(ctx context.Context) error {
@ -63,6 +66,13 @@ func (c *clientSimulator) writeTestCommands(ctx context.Context) error {
const healthInterval = 10 * time.Second
time.Sleep(healthInterval)
c.commands <- &protocol.Command{
Announce: messages.BuildCommandAnnounce(messages.CmdFetchCRL),
Command: &messages.FetchCRLCommand{IssuerID: "sub-ecc_person_2022"},
}
timer := time.NewTimer(healthInterval)
for {
@ -70,15 +80,17 @@ func (c *clientSimulator) writeTestCommands(ctx context.Context) error {
case <-ctx.Done():
_ = timer.Stop()
c.logger.Info("stopping health check loop")
return nil
case <-timer.C:
c.commands <- messages.Command{
Code: messages.CmdHealth,
TimeStamp: time.Now().UTC(),
c.commands <- &protocol.Command{
Announce: messages.BuildCommandAnnounce(messages.CmdHealth),
Command: &messages.HealthCommand{},
}
timer.Reset(healthInterval)
}
timer.Reset(healthInterval)
}
}
@ -90,6 +102,18 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
buf := make([]byte, bufferSize)
type protocolState int8
const (
stAnn protocolState = iota
stResp
)
state := stAnn
var announce []byte
reading:
for {
select {
case <-ctx.Done():
@ -108,12 +132,26 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
data := buf[:count]
err = cobs.Verify(data, cobsConfig)
if err != nil {
return fmt.Errorf("frame verification failed: %w", err)
}
for _, frame := range bytes.SplitAfter(data, []byte{cobsConfig.SpecialByte}) {
if len(frame) == 0 {
continue reading
}
c.responses <- cobs.Decode(data, cobsConfig)
err = cobs.Verify(frame, cobsConfig)
if err != nil {
return fmt.Errorf("frame verification failed: %w", err)
}
if state == stAnn {
announce = cobs.Decode(frame, cobsConfig)
state = stResp
} else {
c.responses <- [][]byte{announce, cobs.Decode(frame, cobsConfig)}
state = stAnn
}
}
}
}
}
@ -122,75 +160,152 @@ func (c *clientSimulator) handleCommands(ctx context.Context) error {
for {
select {
case command := <-c.commands:
commandBytes, err := msgpack.Marshal(command)
if err != nil {
return fmt.Errorf("could not marshal command bytes: %w", err)
if err := writeCommandAnnouncement(command); err != nil {
return err
}
_, err = os.Stdout.Write(cobs.Encode(commandBytes, cobsConfig))
if err != nil {
return fmt.Errorf("write failed: %w", err)
if err := writeCommand(command); err != nil {
return err
}
responseBytes := <-c.responses
respData := <-c.responses
var response messages.Response
c.logger.WithField("respdata", respData).Trace("read response data")
err = msgpack.Unmarshal(responseBytes, &response)
if err != nil {
return fmt.Errorf("could not unmarshal msgpack data: %w", err)
response := &protocol.Response{}
if err := msgpack.Unmarshal(respData[0], &response.Announce); err != nil {
return fmt.Errorf("could not unmarshal response announcement: %w", err)
}
if err := c.handleResponse(response, respData[1]); err != nil {
return err
}
c.logger.Errorf("received response: %+v", response)
case <-ctx.Done():
return nil
}
}
}
func (c *clientSimulator) handleResponse(response *protocol.Response, respBytes []byte) error {
switch response.Announce.Code {
case messages.RespHealth:
data := messages.HealthResponse{}
if err := msgpack.Unmarshal(respBytes, &data); err != nil {
return fmt.Errorf("could not unmarshal health data: %w", err)
}
c.logger.WithField(
"announce",
response.Announce,
).WithField(
"data",
&data,
).Infof("received response")
case messages.RespFetchCRL:
data := messages.FetchCRLResponse{}
if err := msgpack.Unmarshal(respBytes, &data); err != nil {
return fmt.Errorf("could not unmarshal fetch CRL data: %w", err)
}
c.logger.WithField(
"announce",
response.Announce,
).WithField(
"data",
&data,
).Infof("received response")
case messages.RespError:
data := messages.ErrorResponse{}
if err := msgpack.Unmarshal(respBytes, &data); err != nil {
return fmt.Errorf("could not unmarshal error data: %w", err)
}
c.logger.WithField(
"announce",
response.Announce,
).WithField(
"data",
&data,
).Infof("received response")
default:
if err := msgpack.Unmarshal(respBytes, &response.Response); err != nil {
return fmt.Errorf("could not unmarshal response: %w", err)
}
c.logger.WithField("response", response).Infof("received response")
}
return nil
}
func writeCommandAnnouncement(command *protocol.Command) error {
cmdAnnounceBytes, err := msgpack.Marshal(&command.Announce)
if err != nil {
return fmt.Errorf("could not marshal command announcement bytes: %w", err)
}
if _, err = os.Stdout.Write(cobs.Encode(cmdAnnounceBytes, cobsConfig)); err != nil {
return fmt.Errorf("command announcement write failed: %w", err)
}
return nil
}
func writeCommand(command *protocol.Command) error {
cmdBytes, err := msgpack.Marshal(&command.Command)
if err != nil {
return fmt.Errorf("could not marshal command bytes: %w", err)
}
if _, err = os.Stdout.Write(cobs.Encode(cmdBytes, cobsConfig)); err != nil {
return fmt.Errorf("command write failed: %w", err)
}
return nil
}
func (c *clientSimulator) Run() error {
ctx, cancel := context.WithCancel(context.Background())
c.commands = make(chan messages.Command)
c.responses = make(chan []byte)
c.commands = make(chan *protocol.Command)
c.responses = make(chan [][]byte)
wg := sync.WaitGroup{}
wg.Add(2)
var inputError, commandError error
go func(inputErr error) {
_ = c.handleInput(ctx)
go func() {
if err := c.handleInput(ctx); err != nil {
c.logger.WithError(err).Error("input handling failed")
}
cancel()
wg.Done()
}(inputError)
}()
go func(commandErr error) {
_ = c.handleCommands(ctx)
go func() {
if err := c.handleCommands(ctx); err != nil {
c.logger.WithError(err).Error("command handling failed")
}
cancel()
wg.Done()
}(commandError)
}()
var result error
if err := c.writeTestCommands(ctx); err != nil {
c.logger.Errorf("test commands failed: %v", err)
c.logger.WithError(err).Error("test commands failed")
}
cancel()
wg.Wait()
if inputError != nil {
c.logger.Errorf("reading input failed: %v", inputError)
}
if commandError != nil {
c.logger.Errorf("sending commands failed: %v", commandError)
}
return result
}

@ -19,10 +19,13 @@ package main
import (
"flag"
"fmt"
"os"
"github.com/sirupsen/logrus"
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
"git.cacert.org/cacert-gosigner/pkg/config"
"git.cacert.org/cacert-gosigner/pkg/health"
"git.cacert.org/cacert-gosigner/pkg/hsm"
@ -51,7 +54,7 @@ func main() {
logger.SetOutput(os.Stdout)
logger.SetLevel(logrus.InfoLevel)
logger.Infof("cacert-gosigner %s (%s) - built %s\n", version, commit, date)
logger.Infof("cacert-gosigner %s (%s) - built %s", version, commit, date)
flag.StringVar(&signerConfigFile, "config", defaultSignerConfigFile, "signer configuration file")
flag.BoolVar(&showVersion, "version", false, "show version")
@ -67,12 +70,12 @@ func main() {
parsedLevel, err := logrus.ParseLevel(logLevel)
if err != nil {
logger.Fatalf("could not parse log level: %v", err)
logger.WithError(err).Fatal("could not parse log level")
}
logger.SetLevel(parsedLevel)
caConfig := LoadConfig(signerConfigFile, logger)
caConfig := loadConfig(signerConfigFile, logger)
access := initializeHSM(caConfig, setupMode, verbose, logger)
@ -82,23 +85,77 @@ func main() {
healthHandler := health.New(version, access)
proto, err := protocol.New(logger, protocol.RegisterHealthHandler(healthHandler))
revokingRepositories, err := configureRepositories(caConfig)
if err != nil {
logger.WithError(err).Fatal("could not setup revoking repositories")
}
fetchCRLHandler := revoking.NewFetchCRLHandler(revokingRepositories)
proto, err := protocol.New(
logger,
protocol.RegisterHealthHandler(healthHandler),
protocol.RegisterFetchCRLHandler(fetchCRLHandler),
)
if err != nil {
logger.Fatalf("could not setup protocol handler: %v", err)
logger.WithError(err).Fatal("could not setup protocol handler")
}
serialHandler, err := seriallink.New(caConfig.GetSerial(), proto)
if err != nil {
logger.Fatalf("could not setup serial link handler: %v", err)
logger.WithError(err).Fatal("could not setup serial link handler")
}
defer func() { _ = serialHandler.Close() }()
if err = serialHandler.Run(); err != nil {
logger.Fatalf("error in serial handler: %v", err)
logger.WithError(err).Fatal("error in serial handler")
}
logger.Info("setup complete, starting signer operation")
}
func configureRepositories(
caConfig *config.SignerConfig,
) (map[string]*revoking.X509Revoking, error) {
var err error
result := make(map[string]*revoking.X509Revoking)
for _, name := range caConfig.RootCAs() {
result[fmt.Sprintf("root-%s", name)], err = buildX509Revoking(caConfig, name)
if err != nil {
return nil, err
}
}
for _, name := range caConfig.SubordinateCAs() {
result[fmt.Sprintf("sub-%s", name)], err = buildX509Revoking(caConfig, name)
if err != nil {
return nil, err
}
}
return result, nil
}
func buildX509Revoking(caConfig *config.SignerConfig, name string) (*revoking.X509Revoking, error) {
caDef, err := caConfig.GetCADefinition(name)
if err != nil {
return nil, fmt.Errorf("could not get CA definition for %s: %w", name, err)
}
repo, err := caConfig.Repository(name)
if err != nil {
return nil, fmt.Errorf("could not get repository for %s: %w", name, err)
}
logger.Infof("setup complete, starting signer operation")
return revoking.NewX509Revoking(
repo,
caDef.KeyInfo.CRLSignatureAlgorithm,
caDef.Certificate,
caDef.KeyPair,
), nil
}
func initializeHSM(caConfig *config.SignerConfig, setupMode, verbose bool, logger *logrus.Logger) *hsm.Access {
@ -118,21 +175,21 @@ func initializeHSM(caConfig *config.SignerConfig, setupMode, verbose bool, logge
access, err := hsm.NewAccess(logger, opts...)
if err != nil {
logger.Fatalf("could not setup HSM access: %v", err)
logger.WithError(err).Fatal("could not setup HSM access")
}
err = access.EnsureCAKeysAndCertificates()
if err != nil {
logger.Fatalf("could not ensure CA keys and certificates exist: %v", err)
logger.WithError(err).Fatal("could not ensure CA keys and certificates exist")
}
return access
}
func LoadConfig(signerConfigFile string, logger *logrus.Logger) *config.SignerConfig {
func loadConfig(signerConfigFile string, logger *logrus.Logger) *config.SignerConfig {
configFile, err := os.Open(signerConfigFile)
if err != nil {
logger.Fatalf("could not open signer configuration file %s: %v", signerConfigFile, err)
logger.WithError(err).Fatalf("could not open signer configuration file: %s", signerConfigFile)
}
caConfig, err := config.LoadConfiguration(configFile)

@ -6,6 +6,7 @@ require (
github.com/ThalesIgnite/crypto11 v1.2.5
github.com/justincpresley/go-cobs v1.2.0
github.com/shamaton/msgpackgen v0.3.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.0
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
@ -19,7 +20,6 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shamaton/msgpack/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/thales-e-security/pool v0.0.2 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
)

@ -32,7 +32,6 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUY
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/thales-e-security/pool v0.0.2 h1:RAPs4q2EbWsTit6tpzuvTFlgFRJ3S8Evf5gtvVDbmPg=
github.com/thales-e-security/pool v0.0.2/go.mod h1:qtpMm2+thHtqhLzTwgDBj/OuNnMpupY8mv0Phz0gjhU=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

@ -25,12 +25,19 @@ import (
"errors"
"fmt"
"io"
"path"
"strings"
"time"
"gopkg.in/yaml.v3"
"git.cacert.org/cacert-gosigner/pkg/x509/openssl"
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
"git.cacert.org/cacert-gosigner/pkg/x509/signing"
)
const minRSABits = 2048
type Serial struct {
Device string
Baud int
@ -197,10 +204,16 @@ func (k *KeyStorage) UnmarshalYAML(n *yaml.Node) error {
return nil
}
type CARepository interface {
revoking.Repository
signing.Repository
}
type SignerConfig struct {
global *Settings `yaml:"Settings"`
caMap map[string]*CaCertificateEntry `yaml:"CAs"`
keyStorage map[string]*KeyStorage `yaml:"KeyStorage"`
global *Settings `yaml:"Settings"`
caMap map[string]*CaCertificateEntry `yaml:"CAs"`
keyStorage map[string]*KeyStorage `yaml:"KeyStorage"`
repositories map[string]CARepository
}
func (c *SignerConfig) GetCADefinition(label string) (*CaCertificateEntry, error) {
@ -321,6 +334,26 @@ func (c *SignerConfig) GetSerial() *Serial {
return c.global.Serial
}
func (c *SignerConfig) Repository(name string) (CARepository, error) {
var (
repo CARepository
ok bool
err error
)
repo, ok = c.repositories[name]
if !ok {
repo, err = openssl.NewFileRepository(path.Join("repos", name))
if err != nil {
return nil, fmt.Errorf("could not create repository for %s: %w", name, err)
}
c.repositories[name] = repo
}
return repo, nil
}
// LoadConfiguration reads YAML configuration from the given reader as a SignerConfig structure
func LoadConfiguration(r io.Reader) (*SignerConfig, error) {
config := struct {
@ -349,23 +382,26 @@ func LoadConfiguration(r io.Reader) (*SignerConfig, error) {
}
return &SignerConfig{
global: config.Global,
caMap: config.CAs,
keyStorage: config.KeyStorage,
global: config.Global,
caMap: config.CAs,
keyStorage: config.KeyStorage,
repositories: make(map[string]CARepository),
}, nil
}
type PrivateKeyInfo struct {
Algorithm x509.PublicKeyAlgorithm
EccCurve elliptic.Curve
RSABits int
Algorithm x509.PublicKeyAlgorithm
EccCurve elliptic.Curve
RSABits int
CRLSignatureAlgorithm x509.SignatureAlgorithm
}
func (p *PrivateKeyInfo) UnmarshalYAML(value *yaml.Node) error {
internalStructure := struct {
Algorithm string `yaml:"algorithm"`
EccCurve string `yaml:"ecc-curve,omitempty"`
RSABits *int `yaml:"rsa-bits,omitempty"`
Algorithm string `yaml:"algorithm"`
EccCurve string `yaml:"ecc-curve,omitempty"`
RSABits *int `yaml:"rsa-bits,omitempty"`
CRLSignatureAlgorithm string `yaml:"crl-signature-algorithm,omitempty"`
}{}
err := value.Decode(&internalStructure)
@ -382,6 +418,12 @@ func (p *PrivateKeyInfo) UnmarshalYAML(value *yaml.Node) error {
}
p.RSABits = *internalStructure.RSABits
if p.RSABits < minRSABits {
return fmt.Errorf("RSA keys must have a length of at least %d bits", minRSABits)
}
p.CRLSignatureAlgorithm = determineRSASignatureAlgorithm(internalStructure.CRLSignatureAlgorithm)
case "EC":
p.Algorithm = x509.ECDSA
@ -393,6 +435,8 @@ func (p *PrivateKeyInfo) UnmarshalYAML(value *yaml.Node) error {
if err != nil {
return err
}
p.CRLSignatureAlgorithm = determineECDSASignatureAlgorithm(internalStructure.CRLSignatureAlgorithm)
case "":
return errors.New("element 'algorithm' must be specified as 'EC' or 'RSA'")
default:
@ -405,6 +449,32 @@ func (p *PrivateKeyInfo) UnmarshalYAML(value *yaml.Node) error {
return nil
}
func determineRSASignatureAlgorithm(algorithm string) x509.SignatureAlgorithm {
switch strings.ToLower(algorithm) {
case "sha1withrsa", "sha1":
return x509.SHA1WithRSA
case "sha384withrsa", "sha384":
return x509.SHA384WithRSA
case "sha512withrsa", "sha512":
return x509.SHA512WithRSA
default:
return x509.SHA256WithRSA
}
}
func determineECDSASignatureAlgorithm(algorithm string) x509.SignatureAlgorithm {
switch strings.ToLower(algorithm) {
case "sha1withecdsa", "sha1":
return x509.ECDSAWithSHA1
case "sha384withecdsa", "sha384":
return x509.ECDSAWithSHA384
case "sha512withecdsa", "sha512":
return x509.ECDSAWithSHA512
default:
return x509.ECDSAWithSHA256
}
}
func (p *PrivateKeyInfo) MarshalYAML() (interface{}, error) {
internalStructure := struct {
Algorithm string `yaml:"algorithm"`

@ -79,6 +79,8 @@ func (a *Access) Healthy() (*health.Info, error) {
healthy = false
moreInfo[infoKey] = checkFailed
continue
}
moreInfo[infoKey] = fmt.Sprintf("ok, valid until %s", cert.NotAfter.UTC().Format(time.RFC3339))
@ -92,6 +94,8 @@ func (a *Access) Healthy() (*health.Info, error) {
healthy = false
moreInfo[infoKey] = checkFailed
continue
}
def, err := a.signerConfig.GetCADefinition(ca)
@ -99,6 +103,8 @@ func (a *Access) Healthy() (*health.Info, error) {
healthy = false
moreInfo[infoKey] = checkFailed
continue
}
_, err = a.getKeyPair(ca, def.KeyInfo)
@ -106,6 +112,8 @@ func (a *Access) Healthy() (*health.Info, error) {
healthy = false
moreInfo[infoKey] = checkFailed
continue
}
moreInfo[infoKey] = fmt.Sprintf("ok, valid until %s", cert.NotAfter.UTC().Format(time.RFC3339))
@ -307,6 +315,8 @@ func (a *Access) GetSubordinateCACertificate(certLabel string) (*x509.Certificat
return nil, err
}
caCert.Certificate, caCert.KeyPair = certificate, keyPair
return certificate, nil
}

@ -21,58 +21,82 @@ limitations under the License.
package messages
import (
"crypto/x509"
"encoding/pem"
"fmt"
"strings"
"time"
)
type CommandCode int
type CommandCode int8
const (
CmdHealth CommandCode = iota
CmdFetchCRL
)
var commandNames = map[CommandCode]string{
CmdHealth: "HEALTH",
CmdFetchCRL: "FETCH URL",
}
func (c CommandCode) String() string {
switch c {
case CmdHealth:
return "HEALTH"
default:
return fmt.Sprintf("unknown (%d)", int(c))
if name, ok := commandNames[c]; ok {
return name
}
}
type Command struct {
Code CommandCode `msgpack:"code"`
TimeStamp time.Time `msgpack:"created"`
Payload interface{} `msgpack:"payload"` // optional payload
return fmt.Sprintf("unknown %d", c)
}
type ResponseCode int
type ResponseCode int8
const (
RspError ResponseCode = -1
RspHealth ResponseCode = iota
RespError ResponseCode = -1
RespHealth ResponseCode = iota
RespFetchCRL
)
func (r ResponseCode) String() string {
switch r {
case RspError:
return "ERROR"
case RspHealth:
return "HEALTH"
default:
return fmt.Sprintf("unknown (%d)", int(r))
var responseNames = map[ResponseCode]string{
RespError: "ERROR",
RespHealth: "HEALTH",
RespFetchCRL: "FETCH CRL",
}
func (c ResponseCode) String() string {
if name, ok := responseNames[c]; ok {
return name
}
return fmt.Sprintf("unknown %d", c)
}
type CommandAnnounce struct {
Code CommandCode `msgpack:"code"`
Created time.Time `msgpack:"created"`
}
func (r *CommandAnnounce) String() string {
return fmt.Sprintf("CommandAnnounce[code=%s, created=%s]", r.Code, r.Created)
}
type ResponseAnnounce struct {
Code ResponseCode `msgpack:"code"`
Created time.Time `msgpack:"created"`
}
func (r *ResponseAnnounce) String() string {
return fmt.Sprintf("ResponseAnnounce[code=%s, created=%s]", r.Code, r.Created)
}
type Response struct {
Code ResponseCode `msgpack:"code"`
TimeStamp time.Time `msgpack:"created"`
Payload interface{} `msgpack:"payload"`
type FetchCRLCommand struct {
IssuerID string `msgpack:"issuer_id"`
LastKnownHash struct {
Algorithm string `msgpack:"algorithm"`
Value string `msgpack:"value"`
} `msgpack:"last_known_hash"` // optional last known hash in format
}
func (r *Response) String() string {
return fmt.Sprintf("[%s] at %s: %+v", r.Code, r.TimeStamp, r.Payload)
type HealthCommand struct {
}
type HealthInfo struct {
@ -97,10 +121,61 @@ func (i *HealthInfo) String() string {
type HealthResponse struct {
Version string `msgpack:"version"`
Healthy bool
Info []HealthInfo
Healthy bool `msgpack:"healthy"`
Info []*HealthInfo
}
func (h *HealthResponse) String() string {
builder := &strings.Builder{}
_, _ = fmt.Fprintf(builder, "signer version=%s, healthy=%v, health data:\n", h.Version, h.Healthy)
for _, info := range h.Info {
_, _ = fmt.Fprintf(builder, " - %s", info)
}
return builder.String()
}
type FetchCRLResponse struct {
IssuerID string `msgpack:"issuer_id"`
IsDelta bool `msgpack:"is_delta"`
CRLData []byte `msgpack:"crl_data"`
}
func (r *FetchCRLResponse) String() string {
builder := &strings.Builder{}
_, _ = fmt.Fprintf(builder, "issuer id=%s, delta CRL data=%v", r.IssuerID, r.IsDelta)
if r.IsDelta {
_, _ = fmt.Fprint(builder, ", delta CRL data not shown")
} else {
revlist, err := x509.ParseRevocationList(r.CRLData)
if err != nil {
_, _ = fmt.Fprintf(builder, ", could not parse CRL: %s", err.Error())
} else {
_, _ = fmt.Fprintf(builder, ", CRL info: issuer=%s, number=%s, next update=%s, revoked certificates=%d",
revlist.Issuer, revlist.Number, revlist.NextUpdate, len(revlist.RevokedCertificates))
_, _ = builder.WriteString(", CRL data:\n")
_ = pem.Encode(builder, &pem.Block{
Type: "CERTIFICATE REVOCATION LIST",
Bytes: r.CRLData,
})
}
}
return builder.String()
}
type ErrorResponse struct {
Message string `msgpack:"message"`
}
func BuildCommandAnnounce(code CommandCode) *CommandAnnounce {
return &CommandAnnounce{Code: code, Created: time.Now().UTC()}
}
func BuildResponseAnnounce(code ResponseCode) *ResponseAnnounce {
return &ResponseAnnounce{Code: code, Created: time.Now().UTC()}
}

@ -26,6 +26,36 @@ func ___encode(i interface{}) ([]byte, error) {
// encodeAsArray
func ___encodeAsArray(i interface{}) ([]byte, error) {
switch v := i.(type) {
case HealthCommand:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthCommand", size, offset)
}
return b, err
case *HealthCommand:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthCommand", size, offset)
}
return b, err
case HealthInfo:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
@ -86,6 +116,36 @@ func ___encodeAsArray(i interface{}) ([]byte, error) {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthResponse", size, offset)
}
return b, err
case FetchCRLResponse:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeArrayFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "FetchCRLResponse", size, offset)
}
return b, err
case *FetchCRLResponse:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeArrayFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "FetchCRLResponse", size, offset)
}
return b, err
case ErrorResponse:
encoder := enc.NewEncoder()
size, err := ___calcArraySizeErrorResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
@ -123,6 +183,36 @@ func ___encodeAsArray(i interface{}) ([]byte, error) {
// encodeAsMap
func ___encodeAsMap(i interface{}) ([]byte, error) {
switch v := i.(type) {
case HealthCommand:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthCommand", size, offset)
}
return b, err
case *HealthCommand:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthCommand", size, offset)
}
return b, err
case HealthInfo:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
@ -183,6 +273,36 @@ func ___encodeAsMap(i interface{}) ([]byte, error) {
return nil, fmt.Errorf("%s size / offset different %d : %d", "HealthResponse", size, offset)
}
return b, err
case FetchCRLResponse:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeMapFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "FetchCRLResponse", size, offset)
}
return b, err
case *FetchCRLResponse:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder)
if err != nil {
return nil, err
}
encoder.MakeBytes(size)
b, offset, err := ___encodeMapFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, encoder, 0)
if err != nil {
return nil, err
}
if size != offset {
return nil, fmt.Errorf("%s size / offset different %d : %d", "FetchCRLResponse", size, offset)
}
return b, err
case ErrorResponse:
encoder := enc.NewEncoder()
size, err := ___calcMapSizeErrorResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, encoder)
@ -229,6 +349,20 @@ func ___decode(data []byte, i interface{}) (bool, error) {
// decodeAsArray
func ___decodeAsArray(data []byte, i interface{}) (bool, error) {
switch v := i.(type) {
case *HealthCommand:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case **HealthCommand:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *HealthInfo:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
@ -257,6 +391,20 @@ func ___decodeAsArray(data []byte, i interface{}) (bool, error) {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *FetchCRLResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case **FetchCRLResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *ErrorResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeArrayErrorResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
@ -278,6 +426,20 @@ func ___decodeAsArray(data []byte, i interface{}) (bool, error) {
// decodeAsMap
func ___decodeAsMap(data []byte, i interface{}) (bool, error) {
switch v := i.(type) {
case *HealthCommand:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case **HealthCommand:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *HealthInfo:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
@ -306,6 +468,20 @@ func ___decodeAsMap(data []byte, i interface{}) (bool, error) {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *FetchCRLResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case **FetchCRLResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(*v, decoder, 0)
if err == nil && offset != decoder.Len() {
return true, fmt.Errorf("read length is different [%d] [%d] ", offset, decoder.Len())
}
return true, err
case *ErrorResponse:
decoder := dec.NewDecoder(data)
offset, err := ___decodeMapErrorResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v, decoder, 0)
@ -324,6 +500,81 @@ func ___decodeAsMap(data []byte, i interface{}) (bool, error) {
return false, nil
}
// calculate size from git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___calcArraySizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v HealthCommand, encoder *enc.Encoder) (int, error) {
size := 0
size += encoder.CalcStructHeaderFix(0)
return size, nil
}
// calculate size from git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___calcMapSizeHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v HealthCommand, encoder *enc.Encoder) (int, error) {
size := 0
size += encoder.CalcStructHeaderFix(0)
return size, nil
}
// encode from git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___encodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v HealthCommand, encoder *enc.Encoder, offset int) ([]byte, int, error) {
var err error
offset = encoder.WriteStructHeaderFixAsArray(0, offset)
return encoder.EncodedBytes(), offset, err
}
// encode from git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___encodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v HealthCommand, encoder *enc.Encoder, offset int) ([]byte, int, error) {
var err error
offset = encoder.WriteStructHeaderFixAsMap(0, offset)
return encoder.EncodedBytes(), offset, err
}
// decode to git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___decodeArrayHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v *HealthCommand, decoder *dec.Decoder, offset int) (int, error) {
offset, err := decoder.CheckStructHeader(0, offset)
if err != nil {
return 0, err
}
return offset, err
}
// decode to git.cacert.org/cacert-gosigner/pkg/messages.HealthCommand
func ___decodeMapHealthCommand_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v *HealthCommand, decoder *dec.Decoder, offset int) (int, error) {
keys := [][]byte{}
offset, err := decoder.CheckStructHeader(0, offset)
if err != nil {
return 0, err
}
count := 0
for count < 0 {
var dataKey []byte
dataKey, offset, err = decoder.AsStringBytes(offset)
if err != nil {
return 0, err
}
fieldIndex := -1
for i, key := range keys {
if len(dataKey) != len(key) {
continue
}
fieldIndex = i
for dataKeyIndex := range dataKey {
if dataKey[dataKeyIndex] != key[dataKeyIndex] {
fieldIndex = -1
break
}
}
if fieldIndex >= 0 {
break
}
}
switch fieldIndex {
default:
return 0, fmt.Errorf("unknown key[%s] found", string(dataKey))
}
}
return offset, err
}
// calculate size from git.cacert.org/cacert-gosigner/pkg/messages.HealthInfo
func ___calcArraySizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v HealthInfo, encoder *enc.Encoder) (int, error) {
size := 0
@ -562,11 +813,16 @@ func ___calcArraySizeHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81
}
size += s
for _, vv := range v.Info {
size_vv, err := ___calcArraySizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vv, encoder)
if err != nil {
return 0, err
if vv != nil {
vvp := *vv
size_vvp, err := ___calcArraySizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vvp, encoder)
if err != nil {
return 0, err
}
size += size_vvp
} else {
size += encoder.CalcNil()
}
size += size_vv
}
} else {
size += encoder.CalcNil()
@ -590,11 +846,16 @@ func ___calcMapSizeHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a8137
}
size += s
for _, vv := range v.Info {
size_vv, err := ___calcMapSizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vv, encoder)
if err != nil {
return 0, err
if vv != nil {
vvp := *vv
size_vvp, err := ___calcMapSizeHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vvp, encoder)
if err != nil {
return 0, err
}
size += size_vvp
} else {
size += encoder.CalcNil()
}
size += size_vv
}
} else {
size += encoder.CalcNil()
@ -611,9 +872,14 @@ func ___encodeArrayHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a8137
if v.Info != nil {
offset = encoder.WriteSliceLength(len(v.Info), offset, false)
for _, vv := range v.Info {
_, offset, err = ___encodeArrayHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vv, encoder, offset)
if err != nil {
return nil, 0, err
if vv != nil {
vvp := *vv
_, offset, err = ___encodeArrayHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vvp, encoder, offset)
if err != nil {
return nil, 0, err
}
} else {
offset = encoder.WriteNil(offset)
}
}
} else {
@ -628,15 +894,20 @@ func ___encodeMapHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f
offset = encoder.WriteStructHeaderFixAsMap(3, offset)
offset = encoder.WriteStringFix("version", 7, offset)
offset = encoder.WriteString(v.Version, offset)
offset = encoder.WriteStringFix("Healthy", 7, offset)
offset = encoder.WriteStringFix("healthy", 7, offset)
offset = encoder.WriteBool(v.Healthy, offset)
offset = encoder.WriteStringFix("Info", 4, offset)
if v.Info != nil {
offset = encoder.WriteSliceLength(len(v.Info), offset, false)
for _, vv := range v.Info {
_, offset, err = ___encodeMapHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vv, encoder, offset)
if err != nil {
return nil, 0, err
if vv != nil {
vvp := *vv
_, offset, err = ___encodeMapHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(vvp, encoder, offset)
if err != nil {
return nil, 0, err
}
} else {
offset = encoder.WriteNil(offset)
}
}
} else {
@ -668,18 +939,24 @@ func ___decodeArrayHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a8137
v.Healthy = vv
}
if !decoder.IsCodeNil(offset) {
var vv []HealthInfo
var vv []*HealthInfo
var vvl int
vvl, offset, err = decoder.SliceLength(offset)
if err != nil {
return 0, err
}
vv = make([]HealthInfo, vvl)
vv = make([]*HealthInfo, vvl)
for vvi := range vv {
var vvv HealthInfo
offset, err = ___decodeArrayHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(&vvv, decoder, offset)
if err != nil {
return 0, err
var vvv *HealthInfo
if !decoder.IsCodeNil(offset) {
var vvvp HealthInfo
offset, err = ___decodeArrayHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(&vvvp, decoder, offset)
if err != nil {
return 0, err
}
vvv = &vvvp
} else {
offset++
}
vv[vvi] = vvv
}
@ -694,7 +971,7 @@ func ___decodeArrayHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a8137
func ___decodeMapHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v *HealthResponse, decoder *dec.Decoder, offset int) (int, error) {
keys := [][]byte{
{uint8(0x76), uint8(0x65), uint8(0x72), uint8(0x73), uint8(0x69), uint8(0x6f), uint8(0x6e)}, // version
{uint8(0x48), uint8(0x65), uint8(0x61), uint8(0x6c), uint8(0x74), uint8(0x68), uint8(0x79)}, // Healthy
{uint8(0x68), uint8(0x65), uint8(0x61), uint8(0x6c), uint8(0x74), uint8(0x68), uint8(0x79)}, // healthy
{uint8(0x49), uint8(0x6e), uint8(0x66), uint8(0x6f)}, // Info
}
offset, err := decoder.CheckStructHeader(3, offset)
@ -747,22 +1024,239 @@ func ___decodeMapHealthResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f
count++
case 2:
if !decoder.IsCodeNil(offset) {
var vv []HealthInfo
var vv []*HealthInfo
var vvl int
vvl, offset, err = decoder.SliceLength(offset)
if err != nil {
return 0, err
}
vv = make([]HealthInfo, vvl)
vv = make([]*HealthInfo, vvl)
for vvi := range vv {
var vvv HealthInfo
offset, err = ___decodeMapHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(&vvv, decoder, offset)
var vvv *HealthInfo
if !decoder.IsCodeNil(offset) {
var vvvp HealthInfo
offset, err = ___decodeMapHealthInfo_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(&vvvp, decoder, offset)
if err != nil {
return 0, err
}
vvv = &vvvp
} else {
offset++
}
vv[vvi] = vvv
}
v.Info = vv
} else {
offset++
}
count++
default:
return 0, fmt.Errorf("unknown key[%s] found", string(dataKey))
}
}
return offset, err
}
// calculate size from git.cacert.org/cacert-gosigner/pkg/messages.FetchCRLResponse
func ___calcArraySizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v FetchCRLResponse, encoder *enc.Encoder) (int, error) {
size := 0
size += encoder.CalcStructHeaderFix(3)
size += encoder.CalcString(v.IssuerID)
size += encoder.CalcBool(v.IsDelta)
if v.CRLData != nil {
s, err := encoder.CalcSliceLength(len(v.CRLData), true)
if err != nil {
return 0, err
}
size += s
for _, vv := range v.CRLData {
size += encoder.CalcByte(vv)
}
} else {
size += encoder.CalcNil()
}
return size, nil
}
// calculate size from git.cacert.org/cacert-gosigner/pkg/messages.FetchCRLResponse
func ___calcMapSizeFetchCRLResponse_e587a81c7cb163b35488bdef0f58c292f99f4bd65a81377f81e5b18c3d86855d(v FetchCRLResponse, encoder *enc.Encoder) (int, error) {
size := 0
size += encoder.CalcStructHeaderFix(3)
size += encoder.CalcStringFix(9)
size += encoder.CalcString(v.IssuerID)
size += encoder.CalcStringFix(8)
size += encoder.CalcBool(v.IsDelta)
size += encoder.CalcStringFix(8)
if v.CRLData != nil {
s, err := encoder.CalcSliceLength(len(v.CRLData), true)
if err != nil {
return 0, err
}
size += s
for _, vv := range v.CRLData {
size += encoder.CalcByte(vv)