Пример #1
0
        private static IntPtr CipherStr2CipherPtr( PRE_Cipher CC )
        {
            PRE_ptrCipher ptrC = new PRE_ptrCipher
            {
                E = Marshal.StringToHGlobalAuto( CC.E ) ,
                F = Marshal.StringToHGlobalAnsi( CC.F ) ,
                U = Marshal.StringToHGlobalAnsi( CC.U ) ,
                W = Marshal.StringToHGlobalAnsi( CC.W ) ,
            };
            IntPtr C = Marshal.AllocHGlobal( Marshal.SizeOf( ptrC ) );
            Marshal.StructureToPtr( ptrC , C , true );

            return C;
        }
Пример #2
0
        public Boolean DownloadSharingFile(Protocal.SharingInfo si)
        {
            String copyRef = si.Reference;
            String fileName = si.FileName;
            try
            {
                String dropboxPath = BaseExtension.FileStringHelper.GetNonConflictFileName( Path.Combine( DropBoxController.DropBox_DownloadFolder , fileName ) );

                UserKey uk = PreKeyring.UserKey;
                PRE_KEY userKey = new PRE_KEY();
                userKey.PK.PK1 = uk.PK1;
                userKey.PK.PK2 = uk.PK2;
                userKey.SK.X1 = uk.SK1;
                userKey.SK.X2 = uk.SK2;

                PRE_Cipher CKey = new PRE_Cipher();
                CKey.E = si.CKey_E;
                CKey.F = si.CKey_F;
                CKey.U = si.CKey_U;
                CKey.W = si.CKey_W;

                String key = ProxyReEncryption.KeyDecrypt( userKey , CKey );

                FileMetaData fi = new FileMetaData();
                fi.FileName = fileName;
                fi.FilePath = this.dropBoxController.DropboxSecuruStikFolder2SecuruStikFolder( dropboxPath );
                fi.Key = key;
                fi.PlainTextHash = "";
                fi.CryptTextHash = "";
                PreKeyring.FileInfo_Update( fi );

                String dropboxRemotePath = this.dropBoxController.SecuruStikFolder2RemoteDropboxPath( fi.FilePath );
                this.dropBoxController.CopyAsync( copyRef , dropboxRemotePath );
            }
            catch ( System.Exception ex )
            {
                log.ErrorFormat("DownloadSharingFile {0}", si.FileName, ex);
                PreKeyring.SharingFile_Delete( si.Reference );
                return false;
            }
            return true;
        }
Пример #3
0
 public static String KeyDecrypt( PRE_KEY key2 , PRE_Cipher CC )
 {
     IntPtr pKey2 = KeyStr2KeyPtr( key2 );
     IntPtr C = CipherStr2CipherPtr( CC );
     return KeyDecrypt( pKey2 , C );
 }