openwallet-foundation-labs / identity-credential

Apache License 2.0
161 stars 82 forks source link

Support multiple ways to store credential PII and keys #402

Open davidz25 opened 11 months ago

davidz25 commented 11 months ago

There are multiple ways how credential PII and key material is stored and also multiple ways to use this for presentment of the credential. Right now we only support a single method which is storing all the PII in the application's data directory and using a SecureArea implementation (typically Android Keystore) for both CredentialKey and a bunch of single-use DeviceKey (one for each MSO) and then using 18013-5 Device Retrieval for presentation.

Other credential storage methods include

The "Add self-signed document" screen is the first place to start. Today it says "Document type" with options "mDL", "mVR", "micov", "euPID" which are all mdoc specific. Instead it should use words like "Driving License" and for each selected document type we'd also have a list of checkboxes

 Credential Storage formats
  [X] ISO mdoc
  [ ] ISO mdoc Direct Access
  [ ] ISO mdoc w/ Server Retrieval
  [ ] ISO mdoc using Identity Credential API
  [ ] SD-JWT

Notes:

The current design (CredentialStore with one Credential instance per document) is indeed designed with this in mind and the code for each credential storage method can likely be put behind some kind of CredentialStorageAdapter interface. Will follow up with some more thoughts on this.

davidz25 commented 10 months ago

As discussed in today's meeting

// For each Credential Format, an instance of an implementation of this interface exist:
//   MdocDeviceRetrievalAdapter
//   MdocServerRetrievalAdapter
//   MdocDirectAccessAdapter
//
// The application will instantiate these at startup.
//.   
interface CredentialAdapter {

  // At provisioning time
  fun provisionData(credential: Credential, pii: NameSpacedData)

  // At periodic intervals, this is called to e.g. refresh MSO
  fun periodicRefresh()

  // At presentation time, application can query whether a [CredentialStorageAdapter]
  // supports the given [Credential]
  fun isSupportedByCredential(credential: Credential): Boolean

}

// Each [CredentialAdapter] implementation contains specific methods to
// perform the presentation and show format-specific information
// on credential info screen
//
class XXXAdapter : CredentialAdapter {
}