コード例 #1
0
ファイル: MainWindow.cs プロジェクト: nbukovac/NOS_labs
        private void envelopeDecryptStartBtn_Click(object sender, EventArgs e)
        {
            var ready = true;

            if (string.IsNullOrWhiteSpace(envelopeDecryptEnvelope.Text))
            {
                MessageBox.Show("Choose a file for decryption", "Choose envelope", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                ready = false;
            }
            if (string.IsNullOrWhiteSpace(envelopeDecryptPrivate.Text))
            {
                envelopeDecryptPrivate.Text = _initialDirectory + "RSA_private.txt";
            }
            if (string.IsNullOrWhiteSpace(envelopeDecryptPlain.Text))
            {
                envelopeDecryptPlain.Text = _initialDirectory + "envelope_decrypted.txt";
            }

            if (ready)
            {
                DigitalEnvelope.ReadEnvelope(envelopeDecryptEnvelope.Text, int.Parse(rsaKeysSize.Text),
                                             envelopeDecryptPrivate.Text, envelopeDecryptPlain.Text);
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: nbukovac/NOS_labs
        private void envelopeEncryptStart_Click(object sender, EventArgs e)
        {
            var ready = true;

            if (string.IsNullOrWhiteSpace(envelopeEncryptPlain.Text))
            {
                MessageBox.Show("Choose a file for encryption", "Choose plain text", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                ready = false;
            }
            if (string.IsNullOrWhiteSpace(envelopeEncryptPublic.Text))
            {
                envelopeEncryptPlain.Text = _initialDirectory + "RSA_public.txt";
            }
            if (string.IsNullOrWhiteSpace(rsaEncryptCipherFile.Text))
            {
                envelopeEncryptEnvelope.Text = _initialDirectory + "envelope.txt";
            }

            if (ready)
            {
                DigitalEnvelope.CreateEnvelope(envelopeEncryptPlain.Text, int.Parse(rsaKeysSize.Text),
                                               envelopeEncryptPublic.Text, envelopeEncryptEnvelope.Text);
            }
        }
コード例 #3
0
ファイル: SignedEnvelope.cs プロジェクト: nbukovac/NOS_labs
        public static void CreateSignedEnvelope(string plainTextFile, int keySize, string receiverPublicKeyFilePath,
                                                string senderPrivateKeyFilePath, string outputFilePath)
        {
            var tmpEnvelopeFilePath = Environment.CurrentDirectory + @"\Files\tmp\envelope_tmp.txt";

            DigitalEnvelope.CreateEnvelope(plainTextFile, keySize, receiverPublicKeyFilePath,
                                           tmpEnvelopeFilePath);

            DigitalSignature.CreateEnvelopeSignature(tmpEnvelopeFilePath, keySize, senderPrivateKeyFilePath,
                                                     outputFilePath);
        }
コード例 #4
0
ファイル: SignedEnvelope.cs プロジェクト: nbukovac/NOS_labs
        public static bool OpenSignedEnvelope(string signedEnvelopeFilePath, int keySize,
                                              string receiverPrivateKeyFilePath, string senderPublicKeyFilePath, string outputFilePath)
        {
            var verified = DigitalSignature.VerifyEnvelopeSignature(signedEnvelopeFilePath, keySize,
                                                                    senderPublicKeyFilePath);

            var file         = FileOperations.ReadFromTextFile(signedEnvelopeFilePath);
            var fileSplit    = file.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
            var keyBytes     = Converter.HexStringToBytes(fileSplit[4]);
            var messageBytes = Converter.HexStringToBytes(fileSplit[6]);

            DigitalEnvelope.ReadEnvelope(keyBytes, messageBytes, keySize, receiverPrivateKeyFilePath, outputFilePath);

            return(verified);
        }