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
f2060279
Commit
f2060279
authored
Jul 24, 2018
by
Sietse Ringers
Browse files
Remove legacy Android storage conversion
parent
a1a5a6d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmaclient/updates.go
View file @
f2060279
...
...
@@ -2,10 +2,6 @@ package irmaclient
import
(
"encoding/json"
"encoding/xml"
"html"
"io/ioutil"
"math/big"
"regexp"
"time"
...
...
@@ -27,10 +23,7 @@ type update struct {
var
clientUpdates
=
[]
func
(
client
*
Client
)
error
{
// 0: Convert old cardemu.xml Android storage to our own storage format
func
(
client
*
Client
)
error
{
_
,
err
:=
client
.
ParseAndroidStorage
()
return
err
},
nil
,
// No longer necessary as the Android app was deprecated long ago
// 1: Adding scheme manager index, signature and public key
// Check the signatures of all scheme managers, if any is not ok,
...
...
@@ -187,112 +180,3 @@ func (client *Client) update() error {
}
return
err
}
// ParseAndroidStorage parses an Android cardemu.xml shared preferences file
// from the old Android IRMA app, parsing its credentials into the current instance,
// and saving them to storage.
// CAREFUL: this method overwrites any existing secret keys and attributes on storage.
func
(
client
*
Client
)
ParseAndroidStorage
()
(
present
bool
,
err
error
)
{
if
client
.
androidStoragePath
==
""
{
return
false
,
nil
}
cardemuXML
:=
client
.
androidStoragePath
+
"/shared_prefs/cardemu.xml"
present
,
err
=
fs
.
PathExists
(
cardemuXML
)
if
err
!=
nil
||
!
present
{
return
}
present
=
true
bytes
,
err
:=
ioutil
.
ReadFile
(
cardemuXML
)
if
err
!=
nil
{
return
}
parsedxml
:=
struct
{
Strings
[]
struct
{
Name
string
`xml:"name,attr"`
Content
string
`xml:",chardata"`
}
`xml:"string"`
}{}
if
err
=
xml
.
Unmarshal
(
bytes
,
&
parsedxml
);
err
!=
nil
{
return
}
parsedjson
:=
make
(
map
[
string
][]
*
struct
{
Signature
*
gabi
.
CLSignature
`json:"signature"`
Pk
*
gabi
.
PublicKey
`json:"-"`
Attributes
[]
*
big
.
Int
`json:"attributes"`
SharedPoints
[]
*
big
.
Int
`json:"public_sks"`
})
client
.
keyshareServers
=
make
(
map
[
irma
.
SchemeManagerIdentifier
]
*
keyshareServer
)
for
_
,
xmltag
:=
range
parsedxml
.
Strings
{
if
xmltag
.
Name
==
"credentials"
{
jsontag
:=
html
.
UnescapeString
(
xmltag
.
Content
)
if
err
=
json
.
Unmarshal
([]
byte
(
jsontag
),
&
parsedjson
);
err
!=
nil
{
return
}
}
if
xmltag
.
Name
==
"keyshare"
{
jsontag
:=
html
.
UnescapeString
(
xmltag
.
Content
)
if
err
=
json
.
Unmarshal
([]
byte
(
jsontag
),
&
client
.
keyshareServers
);
err
!=
nil
{
return
}
}
if
xmltag
.
Name
==
"KeyshareKeypairs"
{
jsontag
:=
html
.
UnescapeString
(
xmltag
.
Content
)
keys
:=
make
([]
*
paillierPrivateKey
,
0
,
3
)
if
err
=
json
.
Unmarshal
([]
byte
(
jsontag
),
&
keys
);
err
!=
nil
{
return
}
client
.
paillierKeyCache
=
keys
[
0
]
}
}
for
_
,
list
:=
range
parsedjson
{
client
.
secretkey
=
&
secretKey
{
Key
:
list
[
0
]
.
Attributes
[
0
]}
for
_
,
oldcred
:=
range
list
{
gabicred
:=
&
gabi
.
Credential
{
Attributes
:
oldcred
.
Attributes
,
Signature
:
oldcred
.
Signature
,
}
if
oldcred
.
SharedPoints
!=
nil
&&
len
(
oldcred
.
SharedPoints
)
>
0
{
gabicred
.
Signature
.
KeyshareP
=
oldcred
.
SharedPoints
[
0
]
}
var
cred
*
credential
if
cred
,
err
=
newCredential
(
gabicred
,
client
.
Configuration
);
err
!=
nil
{
return
}
if
cred
.
CredentialType
()
==
nil
{
err
=
errors
.
New
(
"cannot add unknown credential type"
)
return
}
if
err
=
client
.
addCredential
(
cred
,
false
);
err
!=
nil
{
return
}
}
}
if
len
(
client
.
credentialsCache
)
>
0
{
if
err
=
client
.
storage
.
StoreAttributes
(
client
.
attributes
);
err
!=
nil
{
return
}
if
err
=
client
.
storage
.
StoreSecretKey
(
client
.
secretkey
);
err
!=
nil
{
return
}
}
if
len
(
client
.
keyshareServers
)
>
0
{
if
err
=
client
.
storage
.
StoreKeyshareServers
(
client
.
keyshareServers
);
err
!=
nil
{
return
}
}
if
err
=
client
.
storage
.
StorePaillierKeys
(
client
.
paillierKeyCache
);
err
!=
nil
{
return
}
if
client
.
paillierKeyCache
==
nil
{
client
.
paillierKey
(
false
)
// trigger calculating a new one
}
return
}
legacy.go
View file @
f2060279
...
...
@@ -4,14 +4,10 @@ import (
"encoding/json"
"math/big"
"strings"
"time"
"github.com/go-errors/errors"
)
// Legacy from the old Android app, and from the protocol that will be updated
// in the future
// Legacy from the protocol that will be updated in the future
// Because the Java version of the current version of the protocol misses a serializer for the Java-equivalent
// of the Java-equivalent of the IssuerIdentifier struct, these get serialized to an ugly map structure that we
...
...
@@ -51,72 +47,3 @@ func (si *SessionInfo) UnmarshalJSON(b []byte) error {
}
return
nil
}
const
(
androidLogVerificationType
=
"verification"
androidLogIssueType
=
"issue"
androidLogSignatureType
=
"signature"
androidLogRemoveType
=
"remove"
androidLogTimeFormat
=
"January 2, 2006 3:04:05 PM MST -07:00"
)
type
androidLogEnvelope
struct
{
Type
string
`json:"type"`
Value
json
.
RawMessage
`json:"value"`
}
func
(
env
*
androidLogEnvelope
)
Parse
()
(
interface
{},
error
)
{
switch
env
.
Type
{
case
androidLogVerificationType
:
val
:=
&
androidLogVerification
{}
return
val
,
json
.
Unmarshal
(
env
.
Value
,
val
)
case
androidLogIssueType
:
val
:=
&
androidLogIssuance
{}
return
val
,
json
.
Unmarshal
(
env
.
Value
,
val
)
case
androidLogSignatureType
:
val
:=
&
androidLogSignature
{}
return
val
,
json
.
Unmarshal
(
env
.
Value
,
val
)
case
androidLogRemoveType
:
val
:=
&
androidLogRemoval
{}
return
val
,
json
.
Unmarshal
(
env
.
Value
,
val
)
default
:
return
nil
,
errors
.
New
(
"Invalid Android log type"
)
}
}
type
androidLogEntry
struct
{
Time
string
`json:"timestamp"`
Credential
struct
{
Identifier
CredentialTypeIdentifier
`json:"identifier"`
}
`json:"credential"`
}
func
(
entry
*
androidLogEntry
)
GetTime
()
Timestamp
{
// An example date directly from cardemu.xml: September 29, 2017 11:12:57 AM GMT+02:00
// Unfortunately, the seemingly appropriate format parameter for time.Parse, with
// "MST-07:00" at the end, makes time.Parse emit an error: "GMT+02" gets to be
// interpreted as the timezone, i.e. as MST, and then nothing gets mapped onto "-07".
// So, we put a space between "GMT" and "+02:00".
fixed
:=
strings
.
Replace
(
entry
.
Time
,
"+"
,
" +"
,
1
)
parsed
,
_
:=
time
.
Parse
(
androidLogTimeFormat
,
fixed
)
return
Timestamp
(
parsed
)
}
type
androidLogIssuance
struct
{
androidLogEntry
}
type
androidLogRemoval
struct
{
androidLogEntry
}
type
androidLogVerification
struct
{
androidLogEntry
Disclosed
map
[
string
]
bool
`json:"attributeDisclosed"`
}
type
androidLogSignature
struct
{
androidLogVerification
Message
string
`json:"message"`
}
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