Skip to content

Commit

Permalink
Update wwwverifier to WD6
Browse files Browse the repository at this point in the history
Modified build scripts to make wwwverifier a subproject of the
Identity Credential project to reduce copy-pasted code. Updated
OriginInfo to match 18013-7 WD6 updates.

Tested appholder changes manually with unattended presentations
via the wwwverifier as well as attended presentations with
appverifier.
  • Loading branch information
suzannajiwani committed Aug 31, 2023
1 parent dcb92f9 commit 90ae45d
Show file tree
Hide file tree
Showing 37 changed files with 583 additions and 5,413 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
.idea/
fastlane/report.xml
/mdl-ref-server/mdl-server-db.sqlite3
/version*
/version*
wwwverifier/build/*
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class MainActivity : AppCompatActivity() {
// TODO: maybe bail in the future if this isn't set.
} else {
logInfo("referrer: $mdocReferrerUri")
originInfos.add(OriginInfoWebsite(1, mdocReferrerUri))
originInfos.add(OriginInfoWebsite(mdocReferrerUri, OriginInfoWebsite.TYPE_BASE))
}

viewModel.startPresentationReverseEngagement(mdocUri, originInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.android.identity.mdoc.origininfo.OriginInfo
import com.android.identity.mdoc.origininfo.OriginInfoQr
import com.android.mdl.app.databinding.FragmentReverseEngagementBinding
import com.android.mdl.app.util.log
import com.android.mdl.app.util.logWarning
Expand Down Expand Up @@ -53,9 +52,7 @@ class ReverseEngagementFragment : Fragment() {
log("qrText: $qrText")
val uri = Uri.parse(qrText)
if (uri.scheme.equals("mdoc")) {
val originInfos = ArrayList<OriginInfo>()
originInfos.add(OriginInfoQr(1))
vm.startPresentationReverseEngagement(qrText, originInfos)
vm.startPresentationReverseEngagement(qrText, null)
findNavController().navigate(
ReverseEngagementFragmentDirections.actionReverseEngagementFragmentToTransferDocumentFragment()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ReverseQrCommunicationSetup(

fun configure(
reverseEngagementUri: String,
origins: List<OriginInfo>
origins: List<OriginInfo>?
) {
val uri = Uri.parse(reverseEngagementUri)
if (!uri.scheme.equals("mdoc")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TransferManager private constructor(private val context: Context) {

fun startPresentationReverseEngagement(
reverseEngagementUri: String,
origins: List<OriginInfo>
origins: List<OriginInfo>?
) {
if (hasStarted) {
throw IllegalStateException("Transfer has already started.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ShareDocumentViewModel(val app: Application) : AndroidViewModel(app) {

fun startPresentationReverseEngagement(
reverseEngagementUri: String,
originInfos: List<OriginInfo>
originInfos: List<OriginInfo>?
) {
if (!hasStarted) {
transferManager.startPresentationReverseEngagement(reverseEngagementUri, originInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public void onConnected() {
EngagementGenerator generator = new EngagementGenerator(
mEDeviceKeyPair.getPublic(),
EngagementGenerator.ENGAGEMENT_VERSION_1_1);
generator.setOriginInfos(mReverseEngagementOriginInfos);
if (mReverseEngagementOriginInfos != null) {
generator.setOriginInfos(mReverseEngagementOriginInfos);
}
mDeviceEngagement = generator.generate();

// 18013-7 says to use ReaderEngagementBytes for Handover when ReaderEngagement
Expand Down Expand Up @@ -713,7 +715,7 @@ public Builder(@NonNull Context context,
*/
public @NonNull Builder useReverseEngagement(@NonNull DataTransport transport,
@Nullable byte[] readerEngagement,
List<OriginInfo> originInfos) {
@Nullable List<OriginInfo> originInfos) {
mHelper.mTransport = transport;
mHelper.mReverseEngagementReaderEngagement = readerEngagement;
mHelper.mReverseEngagementOriginInfos = originInfos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class EngagementGenerator {
private static final String TAG = "EngagementGenerator";
private final String mVersion;
final private PublicKey mESenderKey;
private ArrayBuilder<CborBuilder> mConnectionMethodsArrayBuilder;
private ArrayBuilder<CborBuilder> mDeviceRetrievalMethodsArrayBuilder;
private ArrayBuilder<CborBuilder> mOriginInfoArrayBuilder;

public static final String ENGAGEMENT_VERSION_1_0 = "1.0";
Expand Down Expand Up @@ -75,9 +75,9 @@ public EngagementGenerator(@NonNull PublicKey ESenderKey,
*/
public @NonNull
EngagementGenerator setConnectionMethods(@NonNull List<ConnectionMethod> connectionMethods) {
mConnectionMethodsArrayBuilder = new CborBuilder().addArray();
mDeviceRetrievalMethodsArrayBuilder = new CborBuilder().addArray();
for (ConnectionMethod connectionMethod : connectionMethods) {
mConnectionMethodsArrayBuilder.add(Util.cborDecode(connectionMethod.toDeviceEngagement()));
mDeviceRetrievalMethodsArrayBuilder.add(Util.cborDecode(connectionMethod.toDeviceEngagement()));
}
return this;
}
Expand Down Expand Up @@ -118,8 +118,8 @@ byte[] generate() {
MapBuilder<CborBuilder> map = builder.addMap();
map.put(0, mVersion);
map.put(new UnsignedInteger(1), securityDataItem);
if (mConnectionMethodsArrayBuilder != null) {
map.put(new UnsignedInteger(2), mConnectionMethodsArrayBuilder.end().build().get(0));
if (mDeviceRetrievalMethodsArrayBuilder != null) {
map.put(new UnsignedInteger(2), mDeviceRetrievalMethodsArrayBuilder.end().build().get(0));
}
if (mOriginInfoArrayBuilder != null) {
map.put(new UnsignedInteger(5), mOriginInfoArrayBuilder.end().build().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -305,7 +306,7 @@ void parse(byte[] encodedMobileSecurityObject) {
}

mDigestAlgorithm = Util.cborMapExtractString(mso, "digestAlgorithm");
final List<String> allowableDigestAlgorithms = List.of("SHA-256", "SHA-384", "SHA-512");
final List<String> allowableDigestAlgorithms = Arrays.asList("SHA-256", "SHA-384", "SHA-512");
if (!allowableDigestAlgorithms.contains(mDigestAlgorithm)) {
throw new IllegalArgumentException("Given digest algorithm '" + mDigestAlgorithm +
"' one of " + allowableDigestAlgorithms);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import com.android.identity.internal.Util;

import java.security.cert.X509Certificate;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,7 @@
public abstract class OriginInfo {
private static final String TAG = "OriginInfo";

/**
* The constant used to specify how the current engagement structure is delivered.
*/
public static final long CAT_DELIVERY = 0;

/**
* The constant used to specify how the other party engagement structure has been received.
*/
public static final long CAT_RECEIVE = 1;

/**
* Specifies whether the OriginInfoOptions are about this engagement or the one
* received previously
*
* @return one of {@link #CAT_DELIVERY} or {@link #CAT_RECEIVE}.
*/
public abstract long getCat();
public static final long CAT = 1;

public abstract @NonNull DataItem encode();

Expand All @@ -56,11 +40,8 @@ public abstract class OriginInfo {
}
long type = Util.cborMapExtractNumber(oiDataItem, "type");
switch ((int) type) {
case OriginInfoQr.TYPE:
return OriginInfoQr.decode(oiDataItem);
case OriginInfoNfc.TYPE:
return OriginInfoNfc.decode(oiDataItem);
case OriginInfoWebsite.TYPE:
case OriginInfoWebsite.TYPE_REFERRER:
case OriginInfoWebsite.TYPE_BASE:
return OriginInfoWebsite.decode(oiDataItem);
}
Logger.w(TAG, "Unsupported type " + type);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 90ae45d

Please sign in to comment.