Skip to content
GitLab
Menu
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
8a71e975
Commit
8a71e975
authored
Nov 04, 2017
by
Sietse Ringers
Browse files
Add metadata attribute parsing cli tool
parent
bb5737f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
8a71e975
...
...
@@ -214,6 +214,10 @@ func (attr *MetadataAttribute) setCredentialTypeIdentifier(id string) {
attr
.
setField
(
credentialID
,
bytes
[
:
16
])
}
func
(
attr
*
MetadataAttribute
)
CredentialTypeHash
()
[]
byte
{
return
attr
.
field
(
credentialID
)
}
// Expiry returns the expiry date of this instance
func
(
attr
*
MetadataAttribute
)
Expiry
()
time
.
Time
{
expiry
:=
attr
.
SigningDate
()
.
Unix
()
+
int64
(
attr
.
ValidityDuration
()
*
ExpiryFactor
)
...
...
irmameta/irmameta.go
0 → 100644
View file @
8a71e975
package
main
import
(
"encoding/base64"
"fmt"
"math/big"
"os"
"time"
"encoding/json"
"github.com/credentials/irmago"
"github.com/mhe/gabi"
)
func
main
()
{
if
len
(
os
.
Args
)
!=
3
{
fmt
.
Println
(
"Usage: irmago metadata_attribute_in_decimal path_to_irma_configuration"
)
}
metaint
,
ok
:=
new
(
big
.
Int
)
.
SetString
(
os
.
Args
[
1
],
10
)
if
!
ok
{
fmt
.
Println
(
"Could not parse argument as decimal integer:"
)
os
.
Exit
(
1
)
}
confpath
:=
os
.
Args
[
2
]
conf
,
err
:=
irma
.
NewConfiguration
(
confpath
,
""
)
if
err
!=
nil
{
fmt
.
Println
(
"Failed to parse irma_configuration:"
,
err
)
os
.
Exit
(
1
)
}
err
=
conf
.
ParseFolder
()
if
err
!=
nil
{
fmt
.
Println
(
"Failed to parse irma_configuration:"
,
err
)
os
.
Exit
(
1
)
}
meta
:=
irma
.
MetadataFromInt
(
metaint
,
conf
)
typ
:=
meta
.
CredentialType
()
var
key
*
gabi
.
PublicKey
if
typ
==
nil
{
fmt
.
Println
(
"Unknown credential type, hash:"
,
base64
.
StdEncoding
.
EncodeToString
(
meta
.
CredentialTypeHash
()))
}
else
{
fmt
.
Println
(
"Identifier :"
,
typ
.
Identifier
())
key
,
err
=
meta
.
PublicKey
()
if
err
!=
nil
{
fmt
.
Println
(
"Failed to parse public key"
,
err
)
}
}
fmt
.
Println
(
"Signed :"
,
meta
.
SigningDate
()
.
String
())
fmt
.
Println
(
"Expires :"
,
meta
.
Expiry
()
.
String
())
fmt
.
Println
(
"IsValid() :"
,
meta
.
IsValid
())
fmt
.
Println
(
"KeyCounter :"
,
meta
.
KeyCounter
())
if
key
!=
nil
{
fmt
.
Println
(
"KeyExpires :"
,
time
.
Unix
(
key
.
ExpiryDate
,
0
))
fmt
.
Println
(
"KeyModulusBitlen:"
,
key
.
N
.
BitLen
())
}
fmt
.
Println
()
fmt
.
Println
(
"CredentialType :"
,
prettyprint
(
typ
))
}
func
prettyprint
(
ob
interface
{})
string
{
b
,
err
:=
json
.
MarshalIndent
(
ob
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"error:"
,
err
)
}
return
string
(
b
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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