public BlobChunkVerificationResultInfo Verify(BlobTransportStreamAuthentication expectedAuthentication,
                                                          long blobSize)
            {
                var result = BlobChunkVerificationResultInfo.ValidResult;

                if (BlobSize != blobSize)
                {
                    result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.InvalidBlobSize,
                                                                 BlobChunkVerificationResultContext.Footer, BlobSize);
                }
                else if (Authentication < 0 || Authentication >= BlobTransportStreamAuthentication.kMax)
                {
                    result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.InvalidAuthentication,
                                                                 BlobChunkVerificationResultContext.Footer, Authentication);
                }
                else if (Authentication != expectedAuthentication)
                {
                    result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.AuthenticationMismatch,
                                                                 BlobChunkVerificationResultContext.Footer, Authentication);
                }
                else if (CalculateAssumedAuthenticationDataSize() != Authentication.GetDataSize())
                {
                    result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.InvalidAuthenticationSize,
                                                                 BlobChunkVerificationResultContext.Footer, CalculateAssumedAuthenticationDataSize());
                }

                return(result);
            }
Exemplo n.º 2
0
 void OpenVerifyAssumedStreamSize(ref BlobChunkVerificationResultInfo result)
 {
     if (AssumedStreamSize < kSmallestStreamLength)
     {
         result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.StreamTooSmall,
                                                      BlobChunkVerificationResultContext.Stream, AssumedBlobSize);
     }
 }
Exemplo n.º 3
0
        BlobChunkVerificationResultInfo VerifyEofAuthentication()
        {
            var result = BlobChunkVerificationResultInfo.ValidResult;

            byte[] hash = BuildAuthenticationData();

            if (hash != null)
            {
                bool hashes_equal = hash.EqualsArray(mFooter.AuthenticationData);
                if (!hashes_equal)
                {
                    result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.AuthenticationFailed,
                                                                 BlobChunkVerificationResultContext.Stream);
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        BlobChunkVerificationResultInfo VerifyEnoughBytesForChunkOrData(long totalSize)
        {
            var result = BlobChunkVerificationResultInfo.ValidResult;

            if (UnderlyingStream.IsWriting && EndPosition.IsNone())
            {
                return(result);
            }

            long bytes_remaining = BaseStream.BytesRemaining(EndPosition);

            if (bytes_remaining < totalSize)
            {
                result = new BlobChunkVerificationResultInfo(BlobChunkVerificationResult.EndOfStream,
                                                             BlobChunkVerificationResultContext.Stream, bytes_remaining);
            }

            return(result);
        }