]> Cypherpunks.ru repositories - pygost.git/blobdiff - pygost/mgm.py
Raise copyright years
[pygost.git] / pygost / mgm.py
index 0321628bb16f37138f6d6b00b01d6766c9334140..49c478dc2619b5a00bc40de3e5c3dc5f4294453f 100644 (file)
@@ -1,6 +1,6 @@
 # coding: utf-8
 # PyGOST -- Pure Python GOST cryptographic functions library
-# Copyright (C) 2015-2020 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2015-2021 Sergey Matveev <stargrave@stargrave.org>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-""" Multilinear Galois Mode (MGM) block cipher mode.
+"""Multilinear Galois Mode (MGM) block cipher mode.
 """
 
 from hmac import compare_digest
@@ -57,10 +57,10 @@ class MGM(object):
                              (defaults to blocksize if not specified)
         """
         if bs not in (8, 16):
-            raise ValueError("only 64/128-bit blocksizes allowed")
+            raise ValueError("Only 64/128-bit blocksizes allowed")
         self.tag_size = bs if tag_size is None else bs
         if self.tag_size < 4 or self.tag_size > bs:
-            raise ValueError("invalid tag_size")
+            raise ValueError("Invalid tag_size")
         self.encrypter = encrypter
         self.bs = bs
         self.max_size = (1 << (bs * 8 // 2)) - 1
@@ -74,7 +74,7 @@ class MGM(object):
 
     def _validate_sizes(self, plaintext, additional_data):
         if len(plaintext) == 0 and len(additional_data) == 0:
-            raise ValueError("at least one of plaintext or additional_data required")
+            raise ValueError("At least one of plaintext or additional_data required")
         if len(plaintext) + len(additional_data) > self.max_size:
             raise ValueError("plaintext+additional_data are too big")
 
@@ -164,5 +164,5 @@ class MGM(object):
         )
         tag = self._auth(icn, ciphertext, additional_data)
         if not compare_digest(tag_expected, tag):
-            raise ValueError("invalid authentication tag")
+            raise ValueError("Invalid authentication tag")
         return self._crypt(icn, ciphertext)