Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="protoBatch"> The diagnosis key batch, from which the information to generate the bytes to verify are obtained. Keys inside the batch MUST be sorted</param>
        /// <returns></returns>
        public byte[] Sign(TemporaryExposureKeyGatewayBatchDto protoBatch, SortOrder keysSortOrder)
        {
            MemoryStream memStream = new MemoryStream();

            Func <byte[], string> keyEncodingForSortFunc = keySigBytes => _encodingService.EncodeToBase64(keySigBytes);
            var comparer = StringComparer.Ordinal;

            var query = protoBatch.Keys.Select(GenerateSignaturePayloadFromKey);

            query = (keysSortOrder == SortOrder.ASC) ? query.OrderBy(keyEncodingForSortFunc, comparer) : query.OrderByDescending(keyEncodingForSortFunc, comparer);

            var sortedKeySignatures = query.ToList();

            sortedKeySignatures.ForEach(sig =>
            {
                memStream.Write(sig);
            });

            return(SignWithCertificate(memStream.ToArray()));
        }
Beispiel #2
0
        private TemporaryExposureKeyGatewayBatchProtoDto MapBatchDtoToProtoAndSortForSigning(TemporaryExposureKeyGatewayBatchDto dto)
        {
            var protoKeys = dto.Keys.Select(gatewayDto => _mapper.Map <TemporaryExposureKeyGatewayDtoProto>(gatewayDto)).ToList();

            var protoBatch = new TemporaryExposureKeyGatewayBatchProtoDto();

            protoBatch.Keys.AddRange(protoKeys);

            return(protoBatch);
        }