Пример #1
0
        /// <summary>
        /// encrypts an image
        /// </summary>
        /// <param name="image">the image that will be encrypted</param>
        /// <param name="roIs">the Region of Interests</param>
        /// <param name="password">the password used for encryption</param>
        /// <param name="cryptoFlags">determines which encryption mode will be applied</param>
        /// <param name="errorCode">if an error occurs this value will be set is not 0</param>
        /// <returns>returns an encrypted image</returns>
        public static Image EncryptJPG(Image image, IList <RoI> roIs, string password, CryptoFlags cryptoFlags, out EnumErrorCode errorCode)
        {
            // create JpegOperation from business logic
            IBusinessLogic businessLogic = new BusinessLogic();
            IJpegOperation jpegOperation = businessLogic.CreateJpegOperationBL();

            // convert Image to byte array
            byte[] in_jpegToEncrypt = jpegOperation.ConvertImageToByteArray(image);
            Int32  in_size          = in_jpegToEncrypt.Length;

            // convert RoIs to the correct format
            int counter = 0;

            Int32[] in_roiArray = new Int32[roIs.Count() * 4];
            foreach (RoI roi in roIs)
            {
                in_roiArray[(counter * 4) + 0] = roIs[counter].X;
                in_roiArray[(counter * 4) + 1] = roIs[counter].Y;
                in_roiArray[(counter * 4) + 2] = roIs[counter].Width;
                in_roiArray[(counter * 4) + 3] = roIs[counter].Height;
                counter++;
            }
            Int32 in_roiArraySize = roIs.Count() * 4;

            // create MD5 hash of the password
            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] textToHash           = Encoding.Default.GetBytes(password);
            byte[] in_encryptionKey     = md5.ComputeHash(textToHash);
            Int32  in_encryptionKeySize = in_encryptionKey.Length;

            // convert crypto flags
            byte in_cryptoFlags = cryptoFlags.ToByte();

            // get memory for the encrypted image
            byte[] out_jpegEncrypted     = new byte[in_size * 2];
            byte[] out_statistics        = new byte[in_size];
            IntPtr out_jpegEncryptedSize = new IntPtr();

            int[]    ia2  = new int[1];
            GCHandle gch1 = GCHandle.Alloc(ia2);

            out_jpegEncryptedSize = Marshal.UnsafeAddrOfPinnedArrayElement(ia2, 0);

            // create a pointer for the error code (will be set from C-code)
            IntPtr out_errorCode = new IntPtr();

            int[]    ia  = new int[1];
            GCHandle gch = GCHandle.Alloc(ia);

            out_errorCode = Marshal.UnsafeAddrOfPinnedArrayElement(ia, 0);

            // now try to call the encryption algorithm
            try
            {
                encJpeg(
                    in_jpegToEncrypt,
                    in_size,
                    in_roiArray,
                    in_roiArraySize,
                    in_encryptionKey,
                    in_encryptionKeySize,
                    in_cryptoFlags,
                    out_jpegEncrypted,
                    ref out_jpegEncryptedSize,
                    ref out_errorCode
                    );

                // get the error code
                errorCode = ConvertIntToErrorCode(out_errorCode.ToInt32());

                // truncate byte array
                out_jpegEncrypted = out_jpegEncrypted.Take(out_jpegEncryptedSize.ToInt32()).ToArray();
            }
            catch
            {
                throw new EncryptionException("Error while encrypting!");
            }

            // convert byte array to Image and return
            return(jpegOperation.ConvertByteArrayToImage(out_jpegEncrypted));
        }
Пример #2
0
        public void Test_Encryption_Swap_Values()
        {
            IBusinessLogic businessLogic = BLFactory.CreateBusinessLogic();
            IJpegOperation jpegOperation = businessLogic.CreateJpegOperationBL();

            EnumErrorCode errorCode;

            byte[] planeHEX = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xe1, 0x00, 0x68, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x50, 0x61, 0x69, 0x6e, 0x74, 0x2e, 0x4e, 0x45, 0x54, 0x20, 0x76, 0x33, 0x2e, 0x35, 0x2e, 0x31, 0x30, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 0x05, 0x08, 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b, 0x0c, 0x19, 0x12, 0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24, 0x2e, 0x27, 0x20, 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34, 0x34, 0x1f, 0x27, 0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x09, 0x09, 0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x96, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2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, 0x48, 0xe9, 0xdf, 0x9a, 0x8a, 0xe6, 0xd9, 0x23, 0xb9, 0x31, 0xa9, 0x6d, 0xa4, 0x67, 0x93, 0x45, 0x14, 0xd0, 0xfa, 0x15, 0x42, 0x83, 0x21, 0x1d, 0x3e, 0x62, 0x38, 0xab, 0x0c, 0x04, 0x70, 0xfd, 0xd0, 0xdc, 0xff, 0x00, 0x17, 0xd6, 0x8a, 0x2a, 0x58, 0x90, 0xc9, 0x1f, 0x75, 0xb8, 0xc8, 0x1d, 0x45, 0x42, 0xf0, 0x46, 0xcc, 0x41, 0x1c, 0x28, 0xc8, 0x1f, 0x5a, 0x28, 0xa6, 0xb6, 0x02, 0xb3, 0xe9, 0x76, 0x8a, 0x85, 0x84, 0x5c, 0x9e, 0x7a, 0xfd, 0x69, 0xa6, 0xda, 0x28, 0xa3, 0x60, 0x14, 0x11, 0x81, 0xc1, 0xa2, 0x8a, 0xbb, 0xb6, 0x21, 0xdf, 0x67, 0x89, 0xad, 0x4b, 0x6c, 0x01, 0x87, 0x00, 0x8a, 0x7a, 0x5a, 0xc4, 0xcc, 0xc3, 0x18, 0x00, 0x71, 0x8f, 0xa5, 0x14, 0x52, 0x12, 0x21, 0xba, 0x85, 0x62, 0x20, 0xa9, 0x3f, 0x7b, 0x18, 0xcd, 0x44, 0x54, 0x23, 0xb6, 0x07, 0x43, 0x45, 0x14, 0xc0, 0x40, 0xc4, 0x00, 0x06, 0x30, 0xd9, 0xce, 0x46, 0x7b, 0xd4, 0x80, 0x0f, 0x41, 0xc7, 0xb5, 0x14, 0x50, 0x24, 0x58, 0x48, 0x63, 0x79, 0x1c, 0x95, 0xe9, 0x8e, 0x86, 0x8a, 0x28, 0xa2, 0xe0, 0xf7, 0x3f, 0xff, 0xd9 };
            Image image = jpegOperation.ConvertByteArrayToImage(planeHEX);

            // set encryptio flags
            CryptoFlags cryptoFlags = new CryptoFlags()
            {
                DcCoeffCrypto = false,
                SwapBlock = false,
                SwapCWVPair = false,
                SwapValues = true
            };

            // check encryption calls
            Image encryptedImage = Bridge.EncryptJPG(image, new List<RoI>(), "Password", cryptoFlags, out errorCode);
            Byte[] encryptedImageByteArray = jpegOperation.ConvertImageToByteArray(encryptedImage);

            // check decryption calls
            Image decryptedImage = Bridge.DecryptJPG(encryptedImage, new List<RoI>(), "Password", cryptoFlags, out errorCode);
            Byte[] decryptedImageByteArray = jpegOperation.ConvertImageToByteArray(decryptedImage);

            // check result
            for (int i = 0; i < planeHEX.Length; i++)
                Assert.IsTrue(planeHEX[i] == decryptedImageByteArray[i]);
        }
Пример #3
0
        /// <summary>
        /// encrypts an image
        /// </summary>
        /// <param name="image">the image that will be encrypted</param>
        /// <param name="roIs">the Region of Interests</param>
        /// <param name="password">the password used for encryption</param>
        /// <param name="cryptoFlags">determines which encryption mode will be applied</param>
        /// <param name="errorCode">if an error occurs this value will be set is not 0</param>
        /// <returns>returns an encrypted image</returns>
        public static Image EncryptJPG(Image image, IList<RoI> roIs, string password, CryptoFlags cryptoFlags, out EnumErrorCode errorCode)
        {
            // create JpegOperation from business logic
            IBusinessLogic businessLogic = new BusinessLogic();
            IJpegOperation jpegOperation = businessLogic.CreateJpegOperationBL();

            // convert Image to byte array
            byte[] in_jpegToEncrypt = jpegOperation.ConvertImageToByteArray(image);
            Int32 in_size = in_jpegToEncrypt.Length;

            // convert RoIs to the correct format
            int counter = 0;
            Int32[] in_roiArray = new Int32[roIs.Count() * 4];
            foreach (RoI roi in roIs)
            {
                in_roiArray[(counter * 4) + 0] = roIs[counter].X;
                in_roiArray[(counter * 4) + 1] = roIs[counter].Y;
                in_roiArray[(counter * 4) + 2] = roIs[counter].Width;
                in_roiArray[(counter * 4) + 3] = roIs[counter].Height;
                counter++;
            }
            Int32 in_roiArraySize = roIs.Count() * 4;

            // create MD5 hash of the password
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] textToHash = Encoding.Default.GetBytes(password);
            byte[] in_encryptionKey = md5.ComputeHash(textToHash);
            Int32 in_encryptionKeySize = in_encryptionKey.Length;

            // convert crypto flags 
            byte in_cryptoFlags = cryptoFlags.ToByte();

            // get memory for the encrypted image
            byte[] out_jpegEncrypted = new byte[in_size*2];
            byte[] out_statistics   =  new byte[in_size];
            IntPtr out_jpegEncryptedSize = new IntPtr();
            int[] ia2 = new int[1];
            GCHandle gch1 = GCHandle.Alloc(ia2);
            out_jpegEncryptedSize = Marshal.UnsafeAddrOfPinnedArrayElement(ia2, 0);

            // create a pointer for the error code (will be set from C-code)
            IntPtr out_errorCode = new IntPtr();
            int[] ia = new int[1];
            GCHandle gch = GCHandle.Alloc(ia);
            out_errorCode = Marshal.UnsafeAddrOfPinnedArrayElement(ia, 0);

            // now try to call the encryption algorithm
            try
            {
                encJpeg(
                    in_jpegToEncrypt,
                    in_size,
                    in_roiArray,
                    in_roiArraySize,
                    in_encryptionKey,
                    in_encryptionKeySize,
                    in_cryptoFlags,
                    out_jpegEncrypted,
                    ref out_jpegEncryptedSize,
                    ref out_errorCode
                );

                // get the error code
                errorCode = ConvertIntToErrorCode(out_errorCode.ToInt32());

                // truncate byte array
                out_jpegEncrypted = out_jpegEncrypted.Take(out_jpegEncryptedSize.ToInt32()).ToArray();
            }
            catch 
            {
                throw new EncryptionException("Error while encrypting!");
            }

            // convert byte array to Image and return
            return jpegOperation.ConvertByteArrayToImage(out_jpegEncrypted);
        }
Пример #4
0
        public void Test_Encryption_Test_JPG_progressive()
        {
            // get JPG image with progressive format
            Image image = Image.FromFile(pathToProgressiveJpgImage);

            // set encryption flags
            CryptoFlags cryptoFlags = new CryptoFlags();

            // init error code
            EnumErrorCode errorCode = EnumErrorCode.SUCCESS;

            // check encryption calls
            Image encryptedImage = Bridge.EncryptJPG(image, new List<RoI>(), "Password", cryptoFlags, out errorCode);

            // if an error occurs: encryptedImage is null
            Assert.IsNull(encryptedImage);

            // check correct error message
            Assert.IsTrue(errorCode == EnumErrorCode.UNSUPPORTED);
        }