Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
0da3c2ff
Commit
0da3c2ff
authored
Sep 04, 2018
by
Sietse Ringers
Browse files
Rename CredentialType.Attributes to AttributeTypes
parent
da9fdf3d
Changes
7
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
0da3c2ff
...
...
@@ -83,8 +83,8 @@ func (al *AttributeList) Map(conf *Configuration) map[AttributeTypeIdentifier]Tr
ctid
:=
al
.
CredentialType
()
.
Identifier
()
strings
:=
al
.
Strings
()
ct
:=
conf
.
CredentialTypes
[
ctid
]
for
i
:=
range
ct
.
Attributes
{
attrid
:=
ct
.
Attributes
[
i
]
.
GetAttributeTypeIdentifier
()
for
i
:=
range
ct
.
Attribute
Type
s
{
attrid
:=
ct
.
Attribute
Type
s
[
i
]
.
GetAttributeTypeIdentifier
()
al
.
attrMap
[
attrid
]
=
strings
[
i
]
}
}
...
...
@@ -142,7 +142,7 @@ func (al *AttributeList) UntranslatedAttribute(identifier AttributeTypeIdentifie
if
al
.
CredentialType
()
.
Identifier
()
!=
identifier
.
CredentialTypeIdentifier
()
{
return
nil
}
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attributes
{
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attribute
Type
s
{
if
desc
.
ID
==
string
(
identifier
.
Name
())
{
return
al
.
decode
(
i
)
}
...
...
@@ -155,7 +155,7 @@ func (al *AttributeList) Attribute(identifier AttributeTypeIdentifier) Translate
if
al
.
CredentialType
()
.
Identifier
()
!=
identifier
.
CredentialTypeIdentifier
()
{
return
nil
}
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attributes
{
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attribute
Type
s
{
if
desc
.
ID
==
string
(
identifier
.
Name
())
{
return
al
.
Strings
()[
i
]
}
...
...
descriptions.go
View file @
0da3c2ff
...
...
@@ -54,7 +54,7 @@ type CredentialType struct {
SchemeManagerID
string
`xml:"SchemeManager"`
IsSingleton
bool
`xml:"ShouldBeSingleton"`
Description
TranslatedString
Attribute
s
[]
*
AttributeType
`xml:"Attributes>Attribute" json:"-"`
Attribute
Types
[]
*
AttributeType
`xml:"Attributes>Attribute" json:"-"`
XMLVersion
int
`xml:"version,attr"`
XMLName
xml
.
Name
`xml:"IssueSpecification"`
...
...
@@ -91,7 +91,7 @@ func (ct *CredentialType) ContainsAttribute(ai AttributeTypeIdentifier) bool {
if
ai
.
CredentialTypeIdentifier
()
.
String
()
!=
ct
.
Identifier
()
.
String
()
{
return
false
}
for
_
,
desc
:=
range
ct
.
Attributes
{
for
_
,
desc
:=
range
ct
.
Attribute
Type
s
{
if
desc
.
ID
==
ai
.
Name
()
{
return
true
}
...
...
@@ -105,7 +105,7 @@ func (ct CredentialType) IndexOf(ai AttributeTypeIdentifier) (int, error) {
if
ai
.
CredentialTypeIdentifier
()
!=
ct
.
Identifier
()
{
return
-
1
,
errors
.
New
(
"Wrong credential type"
)
}
for
i
,
description
:=
range
ct
.
Attributes
{
for
i
,
description
:=
range
ct
.
Attribute
Type
s
{
if
description
.
ID
==
ai
.
Name
()
{
return
i
,
nil
}
...
...
@@ -118,7 +118,7 @@ func (ct CredentialType) AttributeType(ai AttributeTypeIdentifier) *AttributeTyp
if
i
==
-
1
{
return
nil
}
return
ct
.
Attributes
[
i
]
return
ct
.
Attribute
Type
s
[
i
]
}
// TranslatedString is a map of translated strings.
...
...
irmaconfig.go
View file @
0da3c2ff
...
...
@@ -42,7 +42,7 @@ type Configuration struct {
SchemeManagers
map
[
SchemeManagerIdentifier
]
*
SchemeManager
Issuers
map
[
IssuerIdentifier
]
*
Issuer
CredentialTypes
map
[
CredentialTypeIdentifier
]
*
CredentialType
Attribute
s
map
[
AttributeTypeIdentifier
]
*
AttributeType
Attribute
Types
map
[
AttributeTypeIdentifier
]
*
AttributeType
// Path to the irma_configuration folder that this instance represents
Path
string
...
...
@@ -119,7 +119,7 @@ func (conf *Configuration) clear() {
conf
.
SchemeManagers
=
make
(
map
[
SchemeManagerIdentifier
]
*
SchemeManager
)
conf
.
Issuers
=
make
(
map
[
IssuerIdentifier
]
*
Issuer
)
conf
.
CredentialTypes
=
make
(
map
[
CredentialTypeIdentifier
]
*
CredentialType
)
conf
.
Attributes
=
make
(
map
[
AttributeTypeIdentifier
]
*
AttributeType
)
conf
.
Attribute
Type
s
=
make
(
map
[
AttributeTypeIdentifier
]
*
AttributeType
)
conf
.
DisabledSchemeManagers
=
make
(
map
[
SchemeManagerIdentifier
]
*
SchemeManagerError
)
conf
.
kssPublicKeys
=
make
(
map
[
SchemeManagerIdentifier
]
map
[
int
]
*
rsa
.
PublicKey
)
conf
.
publicKeys
=
make
(
map
[
IssuerIdentifier
]
map
[
int
]
*
gabi
.
PublicKey
)
...
...
@@ -458,12 +458,12 @@ func (conf *Configuration) parseCredentialsFolder(manager *SchemeManager, issuer
credid
:=
cred
.
Identifier
()
conf
.
CredentialTypes
[
credid
]
=
cred
conf
.
addReverseHash
(
credid
)
for
index
,
attr
:=
range
cred
.
Attributes
{
for
index
,
attr
:=
range
cred
.
Attribute
Type
s
{
attr
.
Index
=
index
attr
.
SchemeManagerID
=
cred
.
SchemeManagerID
attr
.
IssuerID
=
cred
.
IssuerID
attr
.
CredentialTypeID
=
cred
.
ID
conf
.
Attributes
[
attr
.
GetAttributeTypeIdentifier
()]
=
attr
conf
.
Attribute
Type
s
[
attr
.
GetAttributeTypeIdentifier
()]
=
attr
}
return
nil
})
...
...
@@ -725,7 +725,7 @@ func (conf *Configuration) checkCredentialTypes(session SessionRequest, managers
}
// For each of the attributes in the credentialtype, see if it is present; if so remove it from newAttrs
// If not, check that it is optional; if not the credentialtype must be updated
for
_
,
attrtyp
:=
range
typ
.
Attributes
{
for
_
,
attrtyp
:=
range
typ
.
Attribute
Type
s
{
_
,
contains
=
newAttrs
[
attrtyp
.
ID
]
if
!
contains
&&
!
attrtyp
.
IsOptional
()
{
managers
[
credreq
.
CredentialTypeID
.
Root
()]
=
struct
{}{}
...
...
@@ -1076,11 +1076,11 @@ func (conf *Configuration) checkCredentialType(manager *SchemeManager, issuer *I
func
(
conf
*
Configuration
)
checkAttributes
(
cred
*
CredentialType
)
error
{
name
:=
cred
.
Identifier
()
.
String
()
indices
:=
make
(
map
[
int
]
struct
{})
count
:=
len
(
cred
.
Attributes
)
count
:=
len
(
cred
.
Attribute
Type
s
)
if
count
==
0
{
return
errors
.
Errorf
(
"Credenial type %s has no attributes"
,
name
)
}
for
i
,
attr
:=
range
cred
.
Attributes
{
for
i
,
attr
:=
range
cred
.
Attribute
Type
s
{
conf
.
checkTranslations
(
fmt
.
Sprintf
(
"Attribute %s of credential type %s"
,
attr
.
ID
,
cred
.
Identifier
()
.
String
()),
attr
)
index
:=
i
if
attr
.
DisplayIndex
!=
nil
{
...
...
irmago_test.go
View file @
0da3c2ff
...
...
@@ -136,7 +136,7 @@ func TestParseIrmaConfiguration(t *testing.T) {
require
.
Equal
(
t
,
"studentID"
,
conf
.
CredentialTypes
[
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
)]
.
Attributes
[
2
]
.
ID
,
conf
.
CredentialTypes
[
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
)]
.
Attribute
Type
s
[
2
]
.
ID
,
"irma-demo.RU.studentCard.studentID has unexpected name"
)
// Hash algorithm pseudocode:
...
...
requests.go
View file @
0da3c2ff
...
...
@@ -167,7 +167,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error {
// in the credential descriptor.
for
crName
:=
range
cr
.
Attributes
{
found
:=
false
for
_
,
ad
:=
range
credtype
.
Attributes
{
for
_
,
ad
:=
range
credtype
.
Attribute
Type
s
{
if
ad
.
ID
==
crName
{
found
=
true
break
...
...
@@ -178,7 +178,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error {
}
}
for
_
,
attrtype
:=
range
credtype
.
Attributes
{
for
_
,
attrtype
:=
range
credtype
.
Attribute
Type
s
{
if
_
,
present
:=
cr
.
Attributes
[
attrtype
.
ID
];
!
present
&&
attrtype
.
Optional
!=
"true"
{
return
errors
.
New
(
"Required attribute not present in credential request"
)
}
...
...
@@ -204,9 +204,9 @@ func (cr *CredentialRequest) AttributeList(conf *Configuration, metadataVersion
// Compute other attributes
credtype
:=
conf
.
CredentialTypes
[
cr
.
CredentialTypeID
]
attrs
:=
make
([]
*
big
.
Int
,
len
(
credtype
.
Attributes
)
+
1
)
attrs
:=
make
([]
*
big
.
Int
,
len
(
credtype
.
Attribute
Type
s
)
+
1
)
attrs
[
0
]
=
meta
.
Int
for
i
,
attrtype
:=
range
credtype
.
Attributes
{
for
i
,
attrtype
:=
range
credtype
.
Attribute
Type
s
{
attrs
[
i
+
1
]
=
new
(
big
.
Int
)
if
str
,
present
:=
cr
.
Attributes
[
attrtype
.
ID
];
present
{
// Set attribute to str << 1 + 1
...
...
timestamp.go
View file @
0da3c2ff
...
...
@@ -81,7 +81,7 @@ func (sm *SignedMessage) VerifyTimestamp(message string, conf *Configuration) er
if
ct
==
nil
{
return
errors
.
New
(
"Cannot verify timestamp: signature contains attributes from unknown credential type"
)
}
attrcount
:=
len
(
ct
.
Attributes
)
+
2
// plus secret key and metadata
attrcount
:=
len
(
ct
.
Attribute
Type
s
)
+
2
// plus secret key and metadata
disclosed
[
i
]
=
make
([]
*
big
.
Int
,
attrcount
)
for
j
:=
0
;
j
<
attrcount
;
j
++
{
val
,
ok
:=
proofd
.
ADisclosed
[
j
]
...
...
verify.go
View file @
0da3c2ff
...
...
@@ -159,7 +159,7 @@ func (pl ProofList) DisclosedAttributes(configuration *Configuration, disjunctio
p
:=
"present"
attrval
=
&
p
}
else
{
attrid
=
credtype
.
Attributes
[
k
-
2
]
.
GetAttributeTypeIdentifier
()
attrid
=
credtype
.
Attribute
Type
s
[
k
-
2
]
.
GetAttributeTypeIdentifier
()
attrval
=
decodeAttribute
(
v
,
metadata
.
Version
())
}
attr
=
&
DisclosedAttribute
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment