private void StateSboxIntegrate() { double speedratio = parent.sld_EC_Speed.Value; int p, x; TranslateTransform3D tt = new TranslateTransform3D(); p = c_group * 4; for (int i = 3; i >= 0; i--) { p = c_group * 4 + i; x = (int)(parent.cipher.States[c_round, 2] >> p) & 1; gma3D_state[p].Material = material[x, 1]; gma3D_state[p].Transform = tt; c_sel[i] = p; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 2, To = Math.PI * 3 / 2, Scale = 4, Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; if (c_group == 15) { DoubleAnimation da = new DoubleAnimation(opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = speedratio }; brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, da); DoubleAnimation db = new DoubleAnimation(opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = speedratio }; brush[0, 0].BeginAnimation(Brush.OpacityProperty, db); brush[1, 0].BeginAnimation(Brush.OpacityProperty, db); } else { DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(.8))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_low, KeyTime.FromPercent(1))); brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, da); } tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1.5, MethodBase.GetCurrentMethod().Name, speedratio); }
private void KeySboxExtract() { int x, r; TranslateTransform3D tt = new TranslateTransform3D(); r = (int)(parent.cipher.KeyRegs[c_round, 1, 1] >> 60) & 0x0f; for (int i = 0; i < 8; i++) { if (i < 4) { x = (r >> (3 - i)) & 1; } else { x = (parent.cipher.Sbox4[r] >> (7 - i)) & 1; } gma3D_sbox[r, i].Material = material[x, 3]; } for (int i = 76; i < 80; i++) { x = (r >> (i - 76)) & 1; gma3D_keyreg[i].Material = material[x, 3]; gma3D_keyreg[i].Transform = tt; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(1), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation da = new DoubleAnimation(opacity_default, opacity_high, TimeSpan.FromSeconds(1)) { SpeedRatio = parent.sld_KS_Speed.Value }; brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, da); tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1, MethodBase.GetCurrentMethod().Name); }
private void KeyCounterAdd() { c_step = 2; parent.lbl_KS_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[c_step]); int a, b, r, x; a = (int)(parent.cipher.KeyRegs[c_round, 1, 3] & 0xf) << 1; b = (int)(parent.cipher.KeyRegs[c_round, 0, 3] >> 15) & 1; r = a ^ b; parent.lbl_KS_Text.Content = String.Format(Properties.Resources.xor_round_counter, Int2BinaryString(a, 5), Int2BinaryString(b, 5), Int2BinaryString(r, 5)); TranslateTransform3D tt = new TranslateTransform3D(); for (int i = 0; i < 5; i++) { x = (r >> i) & 1; gma3D_roundcountertemp[i].Material = gma3D_keyreg[i + 15].Material; gma3D_roundcountertemp[i].Transform = tt; gma3D_keyreg[i + 15].Material = material[x, 3]; } CosDoubleAnimation day = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(2), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0))); da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0.5))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_default, KeyTime.FromPercent(1))); DoubleAnimationUsingKeyFrames db = da.Clone(); brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, db); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, day); countdown(4, MethodBase.GetCurrentMethod().Name); }
private void KeySboxIntegrate() { TranslateTransform3D tt = new TranslateTransform3D(); for (int i = 76; i < 80; i++) { gma3D_keyreg[i].Transform = tt; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 2, To = Math.PI * 3 / 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(1), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation da = new DoubleAnimation(opacity_high, opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = parent.sld_KS_Speed.Value }; brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, da); tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1, MethodBase.GetCurrentMethod().Name); }
private void StateSboxExtract() { double speedratio = parent.sld_EC_Speed.Value; c_step = 1; //parent.lbl_EC_Text.Content = String.Format("S-Box (0x{1:x16} -> 0x{2:x16})", c_round, parent.cipher.States[c_round, 1], parent.cipher.States[c_round, 2]); parent.lbl_EC_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[c_step]); int p, x, r, s; TranslateTransform3D tt = new TranslateTransform3D(); p = c_group * 4; r = (int)(parent.cipher.States[c_round, 1] >> p) & 0x0f; s = parent.cipher.Sbox4[r]; parent.lbl_EC_Text.Content = String.Format(Properties.Resources.bit_group_sbox, c_group + 1, p + 3, p + 2, p + 1, p, Int2BinaryString(r, 4), Int2BinaryString(s, 4)); for (int i = 0; i < 8; i++) { if (i < 4) { x = (r >> (3 - i)) & 1; } else { x = (s >> (7 - i)) & 1; } gma3D_sbox[r, i].Material = material[x, 1]; } for (int i = Math.Max(0, p - 4); i < p; i++) { x = (int)(parent.cipher.States[c_round, 2] >> i) & 1; gma3D_state[i].Material = material[x, 0]; gma3D_state[i].Transform = null; } for (int i = 3; i >= 0; i--) { p = c_group * 4 + i; x = (int)(parent.cipher.States[c_round, 1] >> p) & 1; gma3D_state[p].Material = material[x, 1]; gma3D_state[p].Transform = tt; c_sel[i] = p; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 4, Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(.2))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(1))); brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, da); if (c_group == 0) { DoubleAnimation db = new DoubleAnimation(opacity_low, TimeSpan.FromSeconds(1)) { SpeedRatio = speedratio }; brush[0, 0].BeginAnimation(Brush.OpacityProperty, db); brush[1, 0].BeginAnimation(Brush.OpacityProperty, db); } tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(2, MethodBase.GetCurrentMethod().Name, speedratio); }