public static PRE_PK GenPK(String pk1, String pk2) { PRE_PK pk = new PRE_PK(); pk.PK1 = pk1; pk.PK2 = pk2; return(pk); }
public static PRE_Cipher KeyEncrypt(PRE_KEY key1, PRE_PK key2_pk, String m) { IntPtr pKey1 = ProxyReEncryption.KeyStr2KeyPtr(key1); IntPtr pPk2 = ProxyReEncryption.PKStr2PKPtr(key2_pk); IntPtr C = KeyEncrypt(pKey1, pPk2, m); PRE_Cipher CC = CipherPtr2CipherStr(C); return(CC); }
private static PRE_KEY KeyPtr2KeyStr(IntPtr keyPtr) { PRE_ptrKEY ptrKey = (PRE_ptrKEY)Marshal.PtrToStructure(keyPtr, typeof(PRE_ptrKEY)); PRE_PK pkey = (PRE_PK)Marshal.PtrToStructure(ptrKey.pk, typeof(PRE_PK)); PRE_SK skey = (PRE_SK)Marshal.PtrToStructure(ptrKey.sk, typeof(PRE_SK)); return(new PRE_KEY { PK = pkey, SK = skey }); }
private static IntPtr PKStr2PKPtr(PRE_PK pk) { PRE_ptrPK ptrPK = new PRE_ptrPK { pk1 = Marshal.StringToHGlobalAnsi(pk.PK1), pk2 = Marshal.StringToHGlobalAnsi(pk.PK2) }; IntPtr pPk = Marshal.AllocHGlobal(Marshal.SizeOf(ptrPK)); Marshal.StructureToPtr(ptrPK, pPk, true); return(pPk); }
private void ShareWorker_DoWork(object sender, DoWorkEventArgs e) { while (this.ShareTaskWaitingList.Count != 0) { for (int i = this.ShareTaskWaitingList.Count - 1; i >= 0; i--) { ShareTaskUnit worker = this.ShareTaskWaitingList[i]; PublicKey pubkey = worker.PK; //Key1 PRE_KEY key = ProxyReEncryption.GenKey( PreKeyring.UserKey.PK1, PreKeyring.UserKey.PK2, PreKeyring.UserKey.SK1, PreKeyring.UserKey.SK2); //Key_pk2 PRE_PK key2_pk = ProxyReEncryption.GenPK(pubkey.PK1, pubkey.PK2); //ReKey PRE_Cipher reKey = ProxyReEncryption.KeyEncrypt(key, key2_pk, worker.Key); String cpyRef = this.DropboxController.GetCopyRef( this.DropboxController.SecuruStikFolder2RemoteDropboxPath(worker.FilePath)); if (String.IsNullOrEmpty(cpyRef)) { continue;//获取copyref失败处理 } else { worker.CpyRef = cpyRef; } SecuruStik.Protocal.SharingInfo si = new SecuruStik.Protocal.SharingInfo( this.Email, pubkey.ID, Path.GetFileName(worker.FilePath), worker.CpyRef, reKey.E, reKey.F, reKey.U, reKey.W); Request r = new Request(MessageType.Request_SetSharingInfo, this.DropboxController.Email, si); this.ProxyServerController.Send(r); this.ShareTaskWaitingList.Remove(worker); SecuruStikMessageQueue.SendMessage_Share_End(Path.GetFileName(worker.FilePath), worker.ID_TO); } } }