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
7b040c80
Commit
7b040c80
authored
Mar 02, 2018
by
Sietse Ringers
Browse files
Fix optional attribute value checking in incoming disclosure requests
parent
b73b7df8
Changes
2
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
7b040c80
...
...
@@ -100,31 +100,40 @@ func (al *AttributeList) Hash() string {
func
(
al
*
AttributeList
)
Strings
()
[]
TranslatedString
{
if
al
.
strings
==
nil
{
al
.
strings
=
make
([]
TranslatedString
,
len
(
al
.
Ints
)
-
1
)
for
index
,
num
:=
range
al
.
Ints
[
1
:
]
{
// skip metadata
bi
:=
new
(
big
.
Int
)
.
Set
(
num
)
if
al
.
MetadataAttribute
.
Version
()
>=
3
{
if
bi
.
Bit
(
0
)
==
0
{
// attribute does not exist
continue
}
bi
=
bi
.
Rsh
(
bi
,
1
)
for
i
:=
range
al
.
Ints
[
1
:
]
{
// skip metadata
val
:=
al
.
decode
(
i
)
if
val
==
nil
{
continue
}
val
:=
string
(
bi
.
Bytes
())
al
.
strings
[
index
]
=
map
[
string
]
string
{
"en"
:
val
,
"nl"
:
val
}
// TODO
al
.
strings
[
i
]
=
map
[
string
]
string
{
"en"
:
*
val
,
"nl"
:
*
val
}
// TODO
}
}
return
al
.
strings
}
func
(
al
*
AttributeList
)
UntranslatedAttribute
(
identifier
AttributeTypeIdentifier
)
string
{
func
(
al
*
AttributeList
)
decode
(
i
int
)
*
string
{
bi
:=
new
(
big
.
Int
)
.
Set
(
al
.
Ints
[
i
+
1
])
if
al
.
MetadataAttribute
.
Version
()
>=
3
{
if
bi
.
Bit
(
0
)
==
0
{
// attribute does not exist
return
nil
}
bi
.
Rsh
(
bi
,
1
)
}
str
:=
string
(
bi
.
Bytes
())
return
&
str
}
// UntranslatedAttribute decodes the bigint corresponding to the specified attribute.
func
(
al
*
AttributeList
)
UntranslatedAttribute
(
identifier
AttributeTypeIdentifier
)
*
string
{
if
al
.
CredentialType
()
.
Identifier
()
!=
identifier
.
CredentialTypeIdentifier
()
{
return
""
return
nil
}
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attributes
{
if
desc
.
ID
==
string
(
identifier
.
Name
())
{
return
string
(
al
.
Ints
[
i
+
1
]
.
Bytes
()
)
return
al
.
decode
(
i
)
}
}
return
""
return
nil
}
// Attribute returns the content of the specified attribute, or "" if not present in this attribute list.
...
...
irmaclient/client.go
View file @
7b040c80
...
...
@@ -450,10 +450,10 @@ func (client *Client) Candidates(disjunction *irma.AttributeDisjunction) []*irma
candidates
=
append
(
candidates
,
id
)
}
else
{
val
:=
attrs
.
UntranslatedAttribute
(
attribute
)
if
val
==
""
{
// This won't handle empty attributes correctly
if
val
==
nil
{
continue
}
if
!
disjunction
.
HasValues
()
||
val
==
disjunction
.
Values
[
attribute
]
{
if
!
disjunction
.
HasValues
()
||
*
val
==
disjunction
.
Values
[
attribute
]
{
candidates
=
append
(
candidates
,
id
)
}
}
...
...
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