Commit 2b18689d authored by Ivar Derksen's avatar Ivar Derksen Committed by Sietse Ringers
Browse files

Fix: load issuance signing date of log in credential info

parent ec005cc7
......@@ -207,7 +207,7 @@ func MetadataFromInt(i *big.Int, conf *Configuration) *MetadataAttribute {
func NewMetadataAttribute(version byte) *MetadataAttribute {
val := MetadataAttribute{new(big.Int), nil, nil}
val.setField(versionField, []byte{version})
val.setSigningDate()
val.setSigningDate(time.Now())
val.setKeyCounter(0)
val.setDefaultValidityDuration()
return &val
......@@ -249,8 +249,8 @@ func (attr *MetadataAttribute) SigningDate() time.Time {
return time.Unix(timestamp, 0)
}
func (attr *MetadataAttribute) setSigningDate() {
attr.setField(signingDateField, shortToByte(uint(time.Now().Unix()/ExpiryFactor)))
func (attr *MetadataAttribute) setSigningDate(issuedAt time.Time) {
attr.setField(signingDateField, shortToByte(uint(issuedAt.Unix()/ExpiryFactor)))
}
// KeyCounter return the public key counter of the metadata attribute
......
......@@ -927,10 +927,12 @@ func (client *Client) ConstructCredentials(msg []*gabi.IssueSignatureMessage, re
if sig.NonRevocationWitness != nil {
nonrevAttr = sig.NonRevocationWitness.E
}
issuedAt := time.Now()
attrs, err := request.Credentials[i-offset].AttributeList(
client.Configuration,
irma.GetMetadataVersion(request.Base().ProtocolVersion),
nonrevAttr,
issuedAt,
)
if err != nil {
return err
......
......@@ -100,7 +100,7 @@ func (entry *LogEntry) GetIssuedCredentials(conf *irma.Configuration) (list irma
if err != nil {
return nil, err
}
return request.(*irma.IssuanceRequest).GetCredentialInfoList(conf, entry.Version)
return request.(*irma.IssuanceRequest).GetCredentialInfoList(conf, entry.Version, time.Time(entry.Time))
}
// GetSignedMessage gets the signed for a log entry
......
......@@ -291,7 +291,8 @@ func (session *session) processSessionInfo() {
if session.Action == irma.ActionIssuing {
ir := session.request.(*irma.IssuanceRequest)
_, err := ir.GetCredentialInfoList(session.client.Configuration, session.Version)
issuedAt := time.Now()
_, err := ir.GetCredentialInfoList(session.client.Configuration, session.Version, issuedAt)
if err != nil {
session.fail(&irma.SessionError{ErrorType: irma.ErrorUnknownIdentifier, Err: err})
return
......
......@@ -558,8 +558,8 @@ func (dr *DisclosureRequest) Validate() error {
return nil
}
func (cr *CredentialRequest) Info(conf *Configuration, metadataVersion byte) (*CredentialInfo, error) {
list, err := cr.AttributeList(conf, metadataVersion, nil)
func (cr *CredentialRequest) Info(conf *Configuration, metadataVersion byte, issuedAt time.Time) (*CredentialInfo, error) {
list, err := cr.AttributeList(conf, metadataVersion, nil, issuedAt)
if err != nil {
return nil, err
}
......@@ -608,6 +608,7 @@ func (cr *CredentialRequest) AttributeList(
conf *Configuration,
metadataVersion byte,
revocationAttr *big.Int,
issuedAt time.Time,
) (*AttributeList, error) {
if err := cr.Validate(conf); err != nil {
return nil, err
......@@ -622,7 +623,7 @@ func (cr *CredentialRequest) AttributeList(
meta := NewMetadataAttribute(metadataVersion)
meta.setKeyCounter(cr.KeyCounter)
meta.setCredentialTypeIdentifier(cr.CredentialTypeID.String())
meta.setSigningDate()
meta.setSigningDate(issuedAt)
if err := meta.setExpiryDate(cr.Validity); err != nil {
return nil, err
}
......@@ -685,10 +686,14 @@ func (ir *IssuanceRequest) Identifiers() *IrmaIdentifierSet {
return ir.ids
}
func (ir *IssuanceRequest) GetCredentialInfoList(conf *Configuration, version *ProtocolVersion) (CredentialInfoList, error) {
func (ir *IssuanceRequest) GetCredentialInfoList(
conf *Configuration,
version *ProtocolVersion,
issuedAt time.Time,
) (CredentialInfoList, error) {
if ir.CredentialInfoList == nil {
for _, credreq := range ir.Credentials {
info, err := credreq.Info(conf, GetMetadataVersion(version))
info, err := credreq.Info(conf, GetMetadataVersion(version), issuedAt)
if err != nil {
return nil, err
}
......
......@@ -158,7 +158,8 @@ func (session *session) computeAttributes(
nonrevAttr = witness.E
}
attributes, err := cred.AttributeList(session.conf.IrmaConfiguration, 0x03, nonrevAttr)
issuedAt := time.Now()
attributes, err := cred.AttributeList(session.conf.IrmaConfiguration, 0x03, nonrevAttr, issuedAt)
if err != nil {
return nil, nil, err
}
......@@ -168,7 +169,7 @@ func (session *session) computeAttributes(
PKCounter: &sk.Counter,
Key: cred.RevocationKey,
Attr: (*irma.RevocationAttribute)(nonrevAttr),
Issued: time.Now().UnixNano(), // or (floored) cred issuance time?
Issued: attributes.SigningDate().UnixNano(),
ValidUntil: attributes.Expiry().UnixNano(),
}
if witness != nil {
......
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