elgamal

Why doesn't my implementation of ElGamal work for long text strings?

元气小坏坏 提交于 2020-01-15 11:10:09
问题 I'm playing with the El Gamal cryptosystem, and my goal is to be able to encipher and decipher long sequences of text. El Gamal requires the plaintext to be an integer. I have turned my string into a byte[] using the .getBytes() method for Strings, and then created a BigInteger out of the byte[]. After encryption/decryption, I turn the BigInteger into a byte[] using the .toByteArray() method for BigIntegers, and then create a new String object from the byte[]. I am using a 1035 bit key, and

Convert plaintext to perform elgamal encryption

笑着哭i 提交于 2020-01-06 03:28:08
问题 Hi i'm writing a program in java to test a variant of the elgamal encryption, however my problem is not the encryption/decryption chain itself, but how to perform the operations on the input given: a text file. I have a text file with some words in it (for example the content can be: "Hello world, this is a test" ) and i need to perform numeric operations on them like this: ciphertext= (message * y) mod p where y and p are two biginteger . I tried this conversion chain: (reading one string at

BigInteger subtraction in JavaCard

穿精又带淫゛_ 提交于 2020-01-02 21:13:21
问题 I am attempting a proof of concept under very constrained technological conditions. My question is: how to efficiently subtract big integers (represented as byte arrays) in a Java Card? . Now, the details are what make the task tricky. I have access to one smart card. The model is Feitian JavaCOS A22 and runs Java Card 2.2. For full detail, Java Card enables the usage of a very restricted subset of the Java API ( namely, no int , no char , and naturally, no BigInteger ), but it does support a

How can i convert a string into a ZZ number?

◇◆丶佛笑我妖孽 提交于 2019-12-24 06:52:29
问题 I'm using the NTL library to implement ElGamal encryption/decryption algorithm. I've got it to the point that it's working but the algorithm wants the message to be converted to integers so it can be encrypted. So if i input a number like 1234 everything works ok but how would i go to be able to convert a C++ string (std::string) to a ZZ number and then back from that ZZ number to a string? LE : ZZ it's a class that represent a large number. Ex:

ElGamal encryption example?

和自甴很熟 提交于 2019-12-23 15:41:43
问题 I apologise in advance for the n00bishness of asking this question, but I've been stuck for ages and I'm struggling to figure out what to do next. Essentially, I am trying to perform ElGamal encryption on some data. I have been given the public part of an ephemeral key pair and a second static key, as well as some data. If my understanding is correct, this is all I need to perform the encryption, but I'm struggling to figure out how using Crypto++. I've looked endlessly for examples, but I

How to encrypt/decrypt text files using ElGamal

若如初见. 提交于 2019-12-13 14:15:42
问题 I'm trying to encrypt and decrypt text files using ElGamal for my study but it seems that I could not make it work correctly. I have a group of text files ranging from 1kb - 1mb, and I'm using 512bit for my key size. I already know that just like RSA, ELGamal can't encrypt values more than its modulus so as my initial solution, I've decided to divide each file into chunks(which is smaller than its modulus) for me to be able to encrypt it and luckily these solution works for encryption. My

ElGamal on SmartCards

…衆ロ難τιáo~ 提交于 2019-12-11 11:09:30
问题 I was wondering if a smartcard/Javacard is able to perform ElGamal cryptography? Is it implemented anywhere, i.e. is there an API that can be used for such purposes? Cheers! 回答1: The SmartMX family of NXP supports ElGamal, it's in their public data sheets. I don't think I've seen in mentioned in any Java Card implementation though, it's not in the standard so if present, it must be in vendor supplied libs. Probably any Smart Card with a Montgomery multiplier will be able to support ElGamal

What are good and safe keylength for El-Gamal?

为君一笑 提交于 2019-12-11 03:03:34
问题 What are good keylength for El-Gamal? 回答1: This is really an open-ended question and it depends on what platform you want to use, your performance constraints, who your enemies are et.c. The outdated GnuPG faq sums this up nicely on length of ElGamal keys - notice that GPG currently creates 2048 bit ElGamal keys by default. [...] After all, if the key is large enough to resist a brute-force attack, an eavesdropper will merely switch to some other method for obtaining your plaintext data.

Unidirectional ElGamal Proxy Re-Encryption implementation

心不动则不痛 提交于 2019-12-08 06:24:39
问题 I've implemented an ElGamal scheme in JavaScript (the code is awful, just wanted to test it quick) based on this explanation. var forge = require('node-forge'); var bigInt = require("big-integer"); var bits = 160; forge.prime.generateProbablePrime(bits, function(err, num) { // Create prime factor and convert to bigInt var factor = bigInt(num.toString(10)); // Find a larger prime of which factor is prime factor // Determine a large even number as a co-factor var coFactor = bigInt.randBetween(

BigInteger subtraction in JavaCard

烂漫一生 提交于 2019-12-06 11:25:01
I am attempting a proof of concept under very constrained technological conditions. My question is: how to efficiently subtract big integers (represented as byte arrays) in a Java Card? . Now, the details are what make the task tricky. I have access to one smart card. The model is Feitian JavaCOS A22 and runs Java Card 2.2. For full detail, Java Card enables the usage of a very restricted subset of the Java API ( namely, no int , no char , and naturally, no BigInteger ), but it does support a series of cryptographic primitives that can be detailed on this list . In particular, my task is to