Пример #1
0
    def update(self, answer):
        self.validate(answer)

        if not self.solved:
            return False

        if self.type == 'submission' and GCE.ENCRYPTION_AVAILABLE:
            self.tip_key = GCE.generate_key()

        return True
Пример #2
0
    def update(self, answer):
        self.validate(answer)

        if not self.solved:
            return False

        if self.type == 'submission' and self.tokenlist.state.tenant_cache[self.tid].encryption:
            self.tip_key = GCE.generate_key()

        return True
Пример #3
0
GCE.ALGORITM_CONFIGURATION['KDF']['ARGON2']['OPSLIMIT'] = GCE.ALGORITM_CONFIGURATION['HASH']['ARGON2']['OPSLIMIT'] = 1
GCE.ALGORITM_CONFIGURATION['HASH']['SCRYPT']['N'] = 1<<1

################################################################################
# BEGIN MOCKS NECESSARY FOR DETERMINISTIC ENCRYPTION
VALID_PASSWORD1 = u'ACollectionOfDiplomaticHistorySince_1966_ToThe_Pr esentDay#'
VALID_PASSWORD2 = VALID_PASSWORD1
VALID_SALT1 = GCE.generate_salt()
VALID_SALT2 = GCE.generate_salt()
VALID_HASH1 = GCE.hash_password(VALID_PASSWORD1, VALID_SALT1)
VALID_HASH2 = GCE.hash_password(VALID_PASSWORD2, VALID_SALT2)
VALID_BASE64_IMG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII='
INVALID_PASSWORD = u'antani'

KEY = GCE.generate_key()
USER_KEY = GCE.derive_key(VALID_PASSWORD1, VALID_SALT1)
USER_PRV_KEY, USER_PUB_KEY = GCE.generate_keypair()
USER_PRV_KEY_ENC = GCE.symmetric_encrypt(USER_KEY, USER_PRV_KEY)
GCE_orig_generate_key = GCE.generate_key
GCE_orig_generate_keypair = GCE.generate_keypair


@staticmethod
def GCE_mock_generate_key():
    return KEY


@staticmethod
def GCE_mock_generate_keypair():
    return USER_PRV_KEY, USER_PUB_KEY
Пример #4
0
GCE.ALGORITM_CONFIGURATION['KDF']['ARGON2']['OPSLIMIT'] = GCE.ALGORITM_CONFIGURATION['HASH']['ARGON2']['OPSLIMIT'] = 1
GCE.ALGORITM_CONFIGURATION['HASH']['SCRYPT']['N'] = 1<<1

################################################################################
# BEGIN MOCKS NECESSARY FOR DETERMINISTIC ENCRYPTION
VALID_PASSWORD1 = u'ACollectionOfDiplomaticHistorySince_1966_ToThe_Pr esentDay#'
VALID_PASSWORD2 = VALID_PASSWORD1
VALID_SALT1 = GCE.generate_salt()
VALID_SALT2 = GCE.generate_salt()
VALID_HASH1 = GCE.hash_password(VALID_PASSWORD1, VALID_SALT1)
VALID_HASH2 = GCE.hash_password(VALID_PASSWORD2, VALID_SALT2)
VALID_BASE64_IMG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII='
INVALID_PASSWORD = u'antani'

KEY = GCE.generate_key()
USER_KEY = GCE.derive_key(VALID_PASSWORD1, VALID_SALT1)
USER_PRV_KEY, USER_PUB_KEY = GCE.generate_keypair()
USER_PRV_KEY_ENC = GCE.symmetric_encrypt(USER_KEY, USER_PRV_KEY)
GCE_orig_generate_key = GCE.generate_key
GCE_orig_generate_keypair = GCE.generate_keypair


@staticmethod
def GCE_mock_generate_key():
    return KEY


@staticmethod
def GCE_mock_generate_keypair():
    return USER_PRV_KEY, USER_PUB_KEY
Пример #5
0
 def test_crypto_generate_key_encrypt_decrypt_key(self):
     enc_key = GCE.generate_key()
     enc = GCE.symmetric_encrypt(enc_key, message)
     dec = GCE.symmetric_decrypt(enc_key, enc)
     self.assertEqual(dec, message)
Пример #6
0
 def test_generate_keypair(self):
     key = GCE.generate_key()
     prv_key, pub_key = GCE.generate_keypair()
     prv_key_enc = GCE.symmetric_encrypt(key, prv_key)
     self.assertEqual(prv_key, GCE.symmetric_decrypt(key, prv_key_enc))
Пример #7
0
 def test_generate_key(self):
     GCE.generate_key()
Пример #8
0
 def test_crypto_generate_key_encrypt_decrypt_key(self):
     enc_key = GCE.generate_key()
     enc = GCE.symmetric_encrypt(enc_key, message)
     dec = GCE.symmetric_decrypt(enc_key, enc)
     self.assertEqual(dec, message)
Пример #9
0
 def test_generate_keypair(self):
     key = GCE.generate_key()
     prv_key, pub_key = GCE.generate_keypair()
     prv_key_enc = GCE.symmetric_encrypt(key, prv_key)
     self.assertEqual(prv_key, GCE.symmetric_decrypt(key, prv_key_enc))
Пример #10
0
 def test_generate_key(self):
     GCE.generate_key()