Unverified Commit 9bbd3c9c authored by Felix Förtsch's avatar Felix Förtsch
Browse files

add hmac

parent d1542001
......@@ -116,7 +116,7 @@ public class FakeManager extends Manager {
ECPublicKey publicKey = checkInManager.getLocationPublicKey(scannerId).blockingGet();
DeviceData deviceData = new DeviceData();
VenueData venueData = new VenueData(cryptoManager, publicKey, deviceData);
VenueData venueData = new VenueData(cryptoManager, publicKey, deviceData, checkInManager);
CheckinData checkinData = new CheckinData(deviceData, venueData);
......@@ -132,50 +132,6 @@ public class FakeManager extends Manager {
return random_bytes;
}
// private QrCodeData generateFakeQrCodeData() {
// UUID userId = UUID.fromString("80caf273-2bbd-42fa-b1d7-0e5309d40d82");
//
// Single<QrCodeData> qrCodeDataSingle = Single.just(new QrCodeData())
// .flatMap(qrCodeData -> cryptoManager.getTraceIdWrapper(userId)
// .flatMapCompletable(userTraceIdWrapper -> Completable.mergeArray(
// cryptoManager.getDailyKeyPairPublicKeyWrapper()
// .map(DailyKeyPairPublicKeyWrapper::getId)
// .doOnSuccess(qrCodeData::setKeyId)
// .ignoreElement(),
// cryptoManager.getUserEphemeralKeyPair(userTraceIdWrapper.getTraceId())
// .observeOn(Schedulers.computation())
// .flatMapCompletable(keyPair -> Completable.mergeArray(
// encryptUserIdAndSecret(userId, keyPair)
// .doOnSuccess(encryptedDataAndIv -> qrCodeData.setEncryptedData(encryptedDataAndIv.first))
// .flatMap(encryptedDataAndIv -> generateVerificationTag(encryptedDataAndIv.first, userTraceIdWrapper.getTimestamp())
// .doOnSuccess(qrCodeData::setVerificationTag))
// .ignoreElement(),
// Single.just(keyPair.getPublic())
// .cast(ECPublicKey.class)
// .flatMap(publicKey -> AsymmetricCipherProvider.encode(publicKey, true))
// .doOnSuccess(qrCodeData::setUserEphemeralPublicKey)
// .ignoreElement()
// )),
// TimeUtil.encodeUnixTimestamp(userTraceIdWrapper.getTimestamp())
// .doOnSuccess(qrCodeData::setTimestamp)
// .ignoreElement(),
// Completable.fromAction(() -> qrCodeData.setTraceId(userTraceIdWrapper.getTraceId()))))
// .andThen(Single.just(qrCodeData)));
//
// return qrCodeDataSingle.blockingGet();
// }
// private CheckInRequestData generateCheckInData(@NonNull QrCodeData qrCodeData, @NonNull PublicKey locationPublicKey) {
//
//
// String serialisedMac = createQrCodeDataMac(encryptedQrCodeData, diffieHellmanSecret)
// .flatMap(SerializationUtil::serializeToBase64).blockingGet();
// checkInRequestData.setMac(serialisedMac);
//
// return checkInRequestData;
// }
public static RegistrationData getFakeRegistrationData() {
RegistrationData registrationData = new RegistrationData();
registrationData.setFirstName(UUID.randomUUID().toString());
......@@ -223,7 +179,7 @@ class VenueData {
String data;
String hmac;
public VenueData(CryptoManager cryptoManager, ECPublicKey publicKey, DeviceData deviceData) {
public VenueData(CryptoManager cryptoManager, ECPublicKey publicKey, DeviceData deviceData, CheckInManager checkInManager) {
KeyPair ephScannerKeys = cryptoManager.generateScannerEphemeralKeyPair().blockingGet();
// dh = Diffie Hellman
......@@ -239,6 +195,9 @@ class VenueData {
.encrypt(deviceData.getDeviceData(), iv, encryptionKey).blockingGet();
this.data = serializeToBase64(encryptedVenueData).blockingGet();
byte[] dataAuthenticationSecret = cryptoManager.generateDataAuthenticationSecret(dhKeys).blockingGet();
byte[] hmac = checkInManager.createQrCodeDataMac(encryptedVenueData, dataAuthenticationSecret).blockingGet();
this.hmac = serializeToBase64(hmac).blockingGet();
}
private String createPublicKeyString(PublicKey ephScannerKeys) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment