diff --git a/decide/base/migrations/0002_auto_20180921_1056.py b/decide/base/migrations/0002_auto_20180921_1056.py new file mode 100644 index 0000000000..e7582f11b2 --- /dev/null +++ b/decide/base/migrations/0002_auto_20180921_1056.py @@ -0,0 +1,33 @@ +# Generated by Django 2.0 on 2018-09-21 10:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='key', + name='g', + field=models.BigIntegerField(), + ), + migrations.AlterField( + model_name='key', + name='p', + field=models.BigIntegerField(), + ), + migrations.AlterField( + model_name='key', + name='x', + field=models.BigIntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name='key', + name='y', + field=models.BigIntegerField(), + ), + ] diff --git a/decide/base/migrations/0003_auto_20180921_1119.py b/decide/base/migrations/0003_auto_20180921_1119.py new file mode 100644 index 0000000000..eef3af603a --- /dev/null +++ b/decide/base/migrations/0003_auto_20180921_1119.py @@ -0,0 +1,34 @@ +# Generated by Django 2.0 on 2018-09-21 11:19 + +import base.models +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0002_auto_20180921_1056'), + ] + + operations = [ + migrations.AlterField( + model_name='key', + name='g', + field=base.models.BigBigField(), + ), + migrations.AlterField( + model_name='key', + name='p', + field=base.models.BigBigField(), + ), + migrations.AlterField( + model_name='key', + name='x', + field=base.models.BigBigField(blank=True, null=True), + ), + migrations.AlterField( + model_name='key', + name='y', + field=base.models.BigBigField(), + ), + ] diff --git a/decide/base/models.py b/decide/base/models.py index 9d21e7a676..c4da20710b 100644 --- a/decide/base/models.py +++ b/decide/base/models.py @@ -1,6 +1,25 @@ from django.db import models +class BigBigField(models.TextField): + def to_python(self, value): + if isinstance(value, str): + return int(value) + if value is None: + return 0 + return int(str(value)) + + def get_prep_value(self, value): + if value is None: + return 0 + return str(value) + + def from_db_value(self, value, expression, connection): + if value is None: + return 0 + return int(value) + + class Auth(models.Model): name = models.CharField(max_length=200) url = models.URLField() @@ -11,10 +30,10 @@ def __str__(self): class Key(models.Model): - p = models.IntegerField() - g = models.IntegerField() - y = models.IntegerField() - x = models.IntegerField(blank=True, null=True) + p = BigBigField() + g = BigBigField() + y = BigBigField() + x = BigBigField(blank=True, null=True) def __str__(self): if self.x: diff --git a/decide/base/serializers.py b/decide/base/serializers.py index fed6cc1792..36d53cff6d 100644 --- a/decide/base/serializers.py +++ b/decide/base/serializers.py @@ -10,6 +10,10 @@ class Meta: class KeySerializer(serializers.HyperlinkedModelSerializer): + p = serializers.IntegerField() + g = serializers.IntegerField() + y = serializers.IntegerField() + class Meta: model = Key fields = ('p', 'g', 'y') diff --git a/decide/booth/static/crypto/elgamal.js b/decide/booth/static/crypto/elgamal.js index 53969df033..b04d573bb7 100644 --- a/decide/booth/static/crypto/elgamal.js +++ b/decide/booth/static/crypto/elgamal.js @@ -1,5 +1,5 @@ ElGamal = {}; -ElGamal.BITS = 8; +ElGamal.BITS = 256; ElGamal.getRandomInteger = function(max) { var bit_length = max.bitLength(); diff --git a/decide/booth/templates/booth/booth.html b/decide/booth/templates/booth/booth.html index bcc3d94826..2933af171b 100644 --- a/decide/booth/templates/booth/booth.html +++ b/decide/booth/templates/booth/booth.html @@ -41,6 +41,7 @@