Commit ad607bd1 authored by Sietse Ringers's avatar Sietse Ringers

fix: private key handling

parent dda57c4d
......@@ -532,8 +532,36 @@ func (conf *Configuration) parseKeysFolder(issuerid IssuerIdentifier) error {
return nil
}
func sorter(ints []uint) func(i, j int) bool {
return func(i, j int) bool { return ints[i] < ints[j] }
}
// unionset returns the concatenation of a and b, without duplicates, and sorted.
func unionset(a, b []uint) []uint {
m := map[uint]struct{}{}
for _, c := range [][]uint{a, b} {
for _, i := range c {
m[i] = struct{}{}
}
}
var ints []uint
for i := range m {
ints = append(ints, i)
}
sort.Slice(ints, sorter(ints))
return ints
}
func (conf *Configuration) PrivateKeyIndices(issuerid IssuerIdentifier) (i []uint, err error) {
return conf.matchKeyPattern(issuerid, privkeyPattern)
filekeys, err := conf.matchKeyPattern(issuerid, privkeyPattern)
if err != nil {
return nil, err
}
var mapkeys []uint
for _, sk := range conf.PrivateKeys[issuerid] {
mapkeys = append(mapkeys, sk.Counter)
}
return unionset(filekeys, mapkeys), nil
}
func (conf *Configuration) PublicKeyIndices(issuerid IssuerIdentifier) (i []uint, err error) {
......@@ -554,7 +582,7 @@ func (conf *Configuration) matchKeyPattern(issuerid IssuerIdentifier, pattern st
}
ints = append(ints, uint(count))
}
sort.Slice(ints, func(i, j int) bool { return ints[i] < ints[j] })
sort.Slice(ints, sorter(ints))
return
}
......
......@@ -78,6 +78,7 @@ func newSqlStorage(debug bool, dbtype, connstr string) (revStorage, error) {
}
func (s sqlRevStorage) Close() error {
Logger.Debug("closing revocation sql database connection")
return s.gorm.Close()
}
......
......@@ -251,7 +251,7 @@ func (conf *Configuration) prepareRevocation(credid irma.CredentialTypeIdentifie
if !exists {
conf.Logger.Warnf("Creating initial accumulator for %s-%d", credid, skcounter)
if err := conf.IrmaConfiguration.Revocation.EnableRevocation(credid, sk); err != nil {
return LogError(errors.WrapPrefix(err, "failed to create initial accumulator record for "+credid.String(), 0))
return LogError(errors.WrapPrefix(err, fmt.Sprintf("failed create initial accumulator for %s-%d", credid, skcounter), 0))
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment