-3.16:
- * 34.10-2012 TC26 twisted Edwards curve related parameters.
- * More test vectors.
+4.0:
+ * 34.10-2012 TC26 twisted Edwards curve related parameters
+ * More test vectors
+ * Backward incompatible Sbox and curves parameters renaming, to
+ comply with OIDs identifying them:
+
+ Gost2814789_TestParamSet -> id-Gost28147-89-TestParamSet
+ Gost28147_CryptoProParamSetA -> id-Gost28147-89-CryptoPro-A-ParamSet
+ Gost28147_CryptoProParamSetB -> id-Gost28147-89-CryptoPro-B-ParamSet
+ Gost28147_CryptoProParamSetC -> id-Gost28147-89-CryptoPro-C-ParamSet
+ Gost28147_CryptoProParamSetD -> id-Gost28147-89-CryptoPro-D-ParamSet
+ Gost28147_tc26_ParamZ -> id-tc26-gost-28147-param-Z
+ GostR3411_94_TestParamSet -> id-GostR3411-94-TestParamSet
+ GostR3411_94_CryptoProParamSet -> id-GostR3411-94-CryptoProParamSet
+
+ GostR3410_2001_TestParamSet -> id-GostR3410-2001-TestParamSet
+ GostR3410_2001_CryptoPro_A_ParamSet -> id-GostR3410-2001-CryptoPro-A-ParamSet
+ GostR3410_2001_CryptoPro_B_ParamSet -> id-GostR3410-2001-CryptoPro-B-ParamSet
+ GostR3410_2001_CryptoPro_C_ParamSet -> id-GostR3410-2001-CryptoPro-C-ParamSet
+ GostR3410_2001_CryptoPro_XchA_ParamSet -> id-GostR3410-2001-CryptoPro-XchA-ParamSet
+ GostR3410_2001_CryptoPro_XchB_ParamSet -> id-GostR3410-2001-CryptoPro-XchB-ParamSet
+ GostR3410_2012_TC26_256_ParamSetA -> id-tc26-gost-3410-2012-256-paramSetA
+ GostR3410_2012_TC26_ParamSetA -> id-tc26-gost-3410-12-512-paramSetA
+ GostR3410_2012_TC26_ParamSetB -> id-tc26-gost-3410-12-512-paramSetB
+ GostR3410_2012_TC26_ParamSetC -> id-tc26-gost-3410-2012-512-paramSetC
3.15:
* Licence changed back to GNU GPLv3+.
>>> from pygost.gost3410 import CURVE_PARAMS
>>> from pygost.gost3410 import GOST3410Curve
- >>> curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ >>> curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
>>> from os import urandom
>>> prv_raw = urandom(32)
>>> from pygost.gost3410 import prv_unmarshal
@table @strong
-@anchor{Release 3.16}
-@item 3.16
+@anchor{Release 4.0}
+@item 4.0
@itemize
@item 34.10-2012 TC26 twisted Edwards curve related parameters
@item More test vectors
+ @item Backward incompatible Sbox and curves parameters renaming,
+ to comply with OIDs identifying them:
+@verbatim
+Gost2814789_TestParamSet -> id-Gost28147-89-TestParamSet
+Gost28147_CryptoProParamSetA -> id-Gost28147-89-CryptoPro-A-ParamSet
+Gost28147_CryptoProParamSetB -> id-Gost28147-89-CryptoPro-B-ParamSet
+Gost28147_CryptoProParamSetC -> id-Gost28147-89-CryptoPro-C-ParamSet
+Gost28147_CryptoProParamSetD -> id-Gost28147-89-CryptoPro-D-ParamSet
+Gost28147_tc26_ParamZ -> id-tc26-gost-28147-param-Z
+GostR3411_94_TestParamSet -> id-GostR3411-94-TestParamSet
+GostR3411_94_CryptoProParamSet -> id-GostR3411-94-CryptoProParamSet
+
+GostR3410_2001_TestParamSet -> id-GostR3410-2001-TestParamSet
+GostR3410_2001_CryptoPro_A_ParamSet -> id-GostR3410-2001-CryptoPro-A-ParamSet
+GostR3410_2001_CryptoPro_B_ParamSet -> id-GostR3410-2001-CryptoPro-B-ParamSet
+GostR3410_2001_CryptoPro_C_ParamSet -> id-GostR3410-2001-CryptoPro-C-ParamSet
+GostR3410_2001_CryptoPro_XchA_ParamSet -> id-GostR3410-2001-CryptoPro-XchA-ParamSet
+GostR3410_2001_CryptoPro_XchB_ParamSet -> id-GostR3410-2001-CryptoPro-XchB-ParamSet
+GostR3410_2012_TC26_256_ParamSetA -> id-tc26-gost-3410-2012-256-paramSetA
+GostR3410_2012_TC26_ParamSetA -> id-tc26-gost-3410-12-512-paramSetA
+GostR3410_2012_TC26_ParamSetB -> id-tc26-gost-3410-12-512-paramSetB
+GostR3410_2012_TC26_ParamSetC -> id-tc26-gost-3410-2012-512-paramSetC
+@end verbatim
@end itemize
@anchor{Release 3.15}
)
# S-box parameters
-DEFAULT_SBOX = "Gost28147_CryptoProParamSetA"
+DEFAULT_SBOX = "id-Gost28147-89-CryptoPro-A-ParamSet"
SBOXES = {
- "Gost2814789_TestParamSet": (
+ "id-Gost28147-89-TestParamSet": (
(4, 2, 15, 5, 9, 1, 0, 8, 14, 3, 11, 12, 13, 7, 10, 6),
(12, 9, 15, 14, 8, 1, 3, 10, 2, 7, 4, 13, 6, 0, 11, 5),
(13, 8, 14, 12, 7, 3, 9, 10, 1, 5, 2, 4, 6, 15, 0, 11),
(9, 11, 12, 0, 3, 6, 7, 5, 4, 8, 14, 15, 1, 10, 2, 13),
(12, 6, 5, 2, 11, 0, 9, 13, 3, 14, 7, 10, 15, 4, 1, 8),
),
- "Gost28147_CryptoProParamSetA": (
+ "id-Gost28147-89-CryptoPro-A-ParamSet": (
(9, 6, 3, 2, 8, 11, 1, 7, 10, 4, 14, 15, 12, 0, 13, 5),
(3, 7, 14, 9, 8, 10, 15, 0, 5, 2, 6, 12, 11, 4, 13, 1),
(14, 4, 6, 2, 11, 3, 13, 8, 12, 15, 5, 10, 0, 7, 1, 9),
(1, 13, 2, 9, 7, 10, 6, 0, 8, 12, 4, 5, 15, 3, 11, 14),
(11, 10, 15, 5, 0, 12, 14, 8, 6, 2, 3, 9, 1, 7, 13, 4),
),
- "Gost28147_CryptoProParamSetB": (
+ "id-Gost28147-89-CryptoPro-B-ParamSet": (
(8, 4, 11, 1, 3, 5, 0, 9, 2, 14, 10, 12, 13, 6, 7, 15),
(0, 1, 2, 10, 4, 13, 5, 12, 9, 7, 3, 15, 11, 8, 6, 14),
(14, 12, 0, 10, 9, 2, 13, 11, 7, 5, 8, 15, 3, 6, 1, 4),
(5, 2, 10, 11, 9, 1, 12, 3, 7, 4, 13, 0, 6, 15, 8, 14),
(0, 4, 11, 14, 8, 3, 7, 1, 10, 2, 9, 6, 15, 13, 5, 12),
),
- "Gost28147_CryptoProParamSetC": (
+ "id-Gost28147-89-CryptoPro-C-ParamSet": (
(1, 11, 12, 2, 9, 13, 0, 15, 4, 5, 8, 14, 10, 7, 6, 3),
(0, 1, 7, 13, 11, 4, 5, 2, 8, 14, 15, 12, 9, 10, 6, 3),
(8, 2, 5, 0, 4, 9, 15, 10, 3, 7, 12, 13, 6, 14, 1, 11),
(10, 9, 6, 8, 13, 14, 2, 0, 15, 3, 5, 11, 4, 1, 12, 7),
(7, 4, 0, 5, 10, 2, 15, 14, 12, 6, 1, 11, 13, 9, 3, 8),
),
- "Gost28147_CryptoProParamSetD": (
+ "id-Gost28147-89-CryptoPro-D-ParamSet": (
(15, 12, 2, 10, 6, 4, 5, 0, 7, 9, 14, 13, 1, 11, 8, 3),
(11, 6, 3, 4, 12, 15, 14, 2, 7, 13, 8, 0, 5, 10, 9, 1),
(1, 12, 11, 0, 15, 14, 6, 5, 10, 13, 4, 8, 9, 3, 7, 2),
(3, 0, 6, 15, 1, 14, 9, 2, 13, 8, 12, 4, 11, 10, 5, 7),
(1, 10, 6, 8, 15, 11, 0, 4, 12, 3, 5, 9, 7, 13, 2, 14),
),
- "GostR3411_94_TestParamSet": (
+ "id-tc26-gost-28147-param-Z": (
+ (12, 4, 6, 2, 10, 5, 11, 9, 14, 8, 13, 7, 0, 3, 15, 1),
+ (6, 8, 2, 3, 9, 10, 5, 12, 1, 14, 4, 7, 11, 13, 0, 15),
+ (11, 3, 5, 8, 2, 15, 10, 13, 14, 1, 7, 4, 12, 9, 6, 0),
+ (12, 8, 2, 1, 13, 4, 15, 6, 7, 0, 10, 5, 3, 14, 9, 11),
+ (7, 15, 5, 10, 8, 1, 6, 13, 0, 9, 3, 14, 11, 4, 2, 12),
+ (5, 13, 15, 6, 9, 2, 12, 10, 11, 7, 8, 1, 4, 3, 14, 0),
+ (8, 14, 2, 5, 6, 9, 1, 12, 15, 4, 11, 0, 13, 10, 3, 7),
+ (1, 7, 14, 13, 0, 5, 8, 3, 4, 15, 10, 6, 9, 12, 11, 2),
+ ),
+ "id-GostR3411-94-TestParamSet": (
(4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3),
(14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9),
(5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9, 11),
(13, 11, 4, 1, 3, 15, 5, 9, 0, 10, 14, 7, 6, 8, 2, 12),
(1, 15, 13, 0, 5, 7, 10, 4, 9, 2, 3, 14, 6, 11, 8, 12),
),
- "GostR3411_94_CryptoProParamSet": (
+ "id-GostR3411-94-CryptoProParamSet": (
(10, 4, 5, 6, 8, 1, 3, 7, 13, 12, 14, 0, 9, 2, 11, 15),
(5, 15, 4, 0, 2, 13, 11, 9, 1, 7, 6, 3, 12, 14, 10, 8),
(7, 15, 12, 14, 9, 4, 1, 0, 3, 11, 5, 2, 6, 10, 8, 13),
(13, 14, 4, 1, 7, 0, 5, 10, 3, 12, 8, 15, 6, 2, 9, 11),
(1, 3, 10, 9, 5, 11, 4, 15, 8, 6, 7, 14, 13, 0, 2, 12),
),
- "Gost28147_tc26_ParamZ": (
- (12, 4, 6, 2, 10, 5, 11, 9, 14, 8, 13, 7, 0, 3, 15, 1),
- (6, 8, 2, 3, 9, 10, 5, 12, 1, 14, 4, 7, 11, 13, 0, 15),
- (11, 3, 5, 8, 2, 15, 10, 13, 14, 1, 7, 4, 12, 9, 6, 0),
- (12, 8, 2, 1, 13, 4, 15, 6, 7, 0, 10, 5, 3, 14, 9, 11),
- (7, 15, 5, 10, 8, 1, 6, 13, 0, 9, 3, 14, 11, 4, 2, 12),
- (5, 13, 15, 6, 9, 2, 12, 10, 11, 7, 8, 1, 4, 3, 14, 0),
- (8, 14, 2, 5, 6, 9, 1, 12, 15, 4, 11, 0, 13, 10, 3, 7),
- (1, 7, 14, 13, 0, 5, 8, 3, 4, 15, 10, 6, 9, 12, 11, 2),
- ),
"EACParamSet": (
(11, 4, 8, 10, 9, 7, 0, 3, 1, 6, 2, 15, 14, 5, 12, 13),
(1, 7, 14, 9, 11, 3, 15, 12, 0, 5, 4, 6, 13, 10, 8, 2),
(7, 14, 12, 13, 9, 4, 8, 15, 10, 2, 6, 0, 3, 11, 5, 1),
),
}
-SBOXES["AppliedCryptography"] = SBOXES["GostR3411_94_TestParamSet"]
+SBOXES["AppliedCryptography"] = SBOXES["id-GostR3411-94-TestParamSet"]
def _K(s, _in):
}
-DEFAULT_CURVE = "GostR3410_2001_CryptoPro_A_ParamSet"
+DEFAULT_CURVE = "id-GostR3410-2001-CryptoPro-A-ParamSet"
# Curve parameters are the following: p, q, a, b, x, y
CURVE_PARAMS = {
"GostR3410_2001_ParamSet_cc": (
"0000000000000000000000000000000000000000000000000000000000000002",
"a20e034bf8813ef5c18d01105e726a17eb248b264ae9706f440bedc8ccb6b22c",
),
- "GostR3410_2001_TestParamSet": (
+ "id-GostR3410-2001-TestParamSet": (
"8000000000000000000000000000000000000000000000000000000000000431",
"8000000000000000000000000000000150FE8A1892976154C59CFC193ACCF5B3",
"0000000000000000000000000000000000000000000000000000000000000007",
"0000000000000000000000000000000000000000000000000000000000000002",
"08E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8",
),
- "GostR3410_2001_CryptoPro_A_ParamSet": (
+ "id-GostR3410-2001-CryptoPro-A-ParamSet": (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94",
"0000000000000000000000000000000000000000000000000000000000000001",
"8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
),
- "GostR3410_2001_CryptoPro_B_ParamSet": (
+ "id-GostR3410-2001-CryptoPro-B-ParamSet": (
"8000000000000000000000000000000000000000000000000000000000000C99",
"800000000000000000000000000000015F700CFFF1A624E5E497161BCC8A198F",
"8000000000000000000000000000000000000000000000000000000000000C96",
"0000000000000000000000000000000000000000000000000000000000000001",
"3FA8124359F96680B83D1C3EB2C070E5C545C9858D03ECFB744BF8D717717EFC",
),
- "GostR3410_2001_CryptoPro_C_ParamSet": (
+ "id-GostR3410-2001-CryptoPro-C-ParamSet": (
"9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
"9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
"9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598",
"0000000000000000000000000000000000000000000000000000000000000000",
"41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
),
- "GostR3410_2001_CryptoPro_XchA_ParamSet": (
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet": (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94",
"0000000000000000000000000000000000000000000000000000000000000001",
"8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
),
- "GostR3410_2001_CryptoPro_XchB_ParamSet": (
+ "id-GostR3410-2001-CryptoPro-XchB-ParamSet": (
"9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
"9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
"9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598",
"0000000000000000000000000000000000000000000000000000000000000000",
"41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
),
- "GostR3410_2012_TC26_256_ParamSetA": (
+ "id-tc26-gost-3410-2012-256-paramSetA": (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
"400000000000000000000000000000000FD8CDDFC87B6635C115AF556C360C67",
"C2173F1513981673AF4892C23035A27CE25E2013BF95AA33B22C656F277E7335",
"91E38443A5E82C0D880923425712B2BB658B9196932E02C78B2582FE742DAA28",
"32879423AB1A0375895786C4BB46E9565FDE0B5344766740AF268ADB32322E5C",
),
- "GostR3410_2012_TC26_ParamSetA": (
+ "id-tc26-gost-3410-12-512-paramSetA": (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF27E69532F48D89116FF22B8D4E0560609B4B38ABFAD2B85DCACDB1411F10B275",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC4",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003",
"7503CFE87A836AE3A61B8816E25450E6CE5E1C93ACF1ABC1778064FDCBEFA921DF1626BE4FD036E93D75E6A50E3A41E98028FE5FC235F5B889A589CB5215F2A4",
),
- "GostR3410_2012_TC26_ParamSetB": (
+ "id-tc26-gost-3410-12-512-paramSetB": (
"8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006F",
"800000000000000000000000000000000000000000000000000000000000000149A1EC142565A545ACFDB77BD9D40CFA8B996712101BEA0EC6346C54374F25BD",
"8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
"1A8F7EDA389B094C2C071E3647A8940F3C123B697578C213BE6DD9E6C8EC7335DCB228FD1EDF4A39152CBCAAF8C0398828041055F94CEEEC7E21340780FE41BD"
),
- "GostR3410_2012_TC26_ParamSetC": (
+ "id-tc26-gost-3410-2012-512-paramSetC": (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7",
"3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC98CDBA46506AB004C33A9FF5147502CC8EDA9E7A769A12694623CEF47F023ED",
"DC9203E514A721875485A529D2C722FB187BC8980EB866644DE41C68E143064546E861C0E2C9EDD92ADE71F46FCF50FF2AD97F951FDA9F2A2EB6546F39689BD3",
class GOST3410Curve(object):
""" GOST 34.10 validated curve
- >>> p, q, a, b, x, y = CURVE_PARAMS["GostR3410_2001_TestParamSet"]
+ >>> p, q, a, b, x, y = CURVE_PARAMS["id-GostR3410-2001-TestParamSet"]
>>> curve = GOST3410Curve(p, q, a, b, x, y)
>>> prv = prv_unmarshal(urandom(32))
>>> signature = sign(curve, prv, GOST341194(data).digest())
"""
return GOST341194(
kek(curve, prv, pub, ukm, mode=2001),
- "GostR3411_94_CryptoProParamSet",
+ "id-GostR3411-94-CryptoProParamSet",
).digest()
from pygost.utils import xrange # pylint: disable=redefined-builtin
-DEFAULT_SBOX = "GostR3411_94_TestParamSet"
+DEFAULT_SBOX = "id-GostR3411-94-CryptoProParamSet"
BLOCKSIZE = 32
C2 = 32 * b"\x00"
C3 = hexdec(b"ff00ffff000000ffff0000ff00ffff0000ff00ff00ff00ffff00ff00ff00ff00")
return GOST341194(data, sbox)
-PBKDF2_HASHER = partial(GOST341194, sbox="GostR3411_94_CryptoProParamSet")
+PBKDF2_HASHER = partial(GOST341194, sbox="id-GostR3411-94-CryptoProParamSet")
def pbkdf2(password, salt, iterations, dklen):
"""
# Backward compatibility key preparation for 28147-89 key schedule
self.key = b"".join(key[i * 4:i * 4 + 4][::-1] for i in range(8))
- self.sbox = "Gost28147_tc26_ParamZ"
+ self.sbox = "id-tc26-gost-28147-param-Z"
def encrypt(self, blk):
return gost28147_ns2block(gost28147_encrypt(
self.process_cms(
content_info_raw,
prv_key_raw,
- "GostR3410_2001_CryptoPro_XchA_ParamSet",
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
GOST34112012256,
2001,
)
self.process_cms(
content_info_raw,
prv_key_raw,
- "GostR3410_2012_TC26_ParamSetB",
+ "id-tc26-gost-3410-12-512-paramSetB",
GOST34112012512,
2012,
)
keker,
plaintext_expected,
):
- sbox = "Gost28147_tc26_ParamZ"
+ sbox = "id-tc26-gost-28147-param-Z"
content_info, tail = ContentInfo().decode(content_info_raw, ctx={
"defines_by_path": [
(
self.process_cms(
content_info_raw,
prv_key_our,
- "GostR3410_2001_CryptoPro_XchA_ParamSet",
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
keker,
b"Test data to encrypt.\n" * 100,
)
self.process_cms(
content_info_raw,
prv_key_our,
- "GostR3410_2012_TC26_ParamSetB",
+ "id-tc26-gost-3410-12-512-paramSetB",
keker,
b"Test message",
)
keker,
plaintext_expected,
):
- sbox = "Gost28147_tc26_ParamZ"
+ sbox = "id-tc26-gost-28147-param-Z"
content_info, tail = ContentInfo().decode(content_info_raw, ctx={
"defines_by_path": [
(
self.process_cms(
content_info_raw,
prv_key_our,
- "GostR3410_2001_CryptoPro_XchA_ParamSet",
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
keker,
b"Test message",
)
self.process_cms(
content_info_raw,
prv_key_our,
- "GostR3410_2012_TC26_ParamSetB",
+ "id-tc26-gost-3410-12-512-paramSetB",
keker,
b"Test message",
)
def test_gcl(self):
""" Test vectors from libgcl3
"""
- sbox = "Gost2814789_TestParamSet"
+ sbox = "id-Gost28147-89-TestParamSet"
key = hexdec(b"0475f6e05038fbfad2c7c390edb3ca3d1547124291ae1e8a2f79cd9ed2bcefbd")
plaintext = bytes(bytearray((
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
def test_cryptomanager(self):
""" Test vector from http://cryptomanager.com/tv.html
"""
- sbox = "GostR3411_94_TestParamSet"
+ sbox = "id-GostR3411-94-TestParamSet"
key = hexdec(b"75713134B60FEC45A607BB83AA3746AF4FF99DA6D1B53B5B1B402A1BAA030D1B")
self.assertSequenceEqual(
ecb_encrypt(key, hexdec(b"1122334455667788"), sbox=sbox),
""" Test vector from http://cryptomanager.com/tv.html
"""
key = hexdec(b"75713134B60FEC45A607BB83AA3746AF4FF99DA6D1B53B5B1B402A1BAA030D1B")
- sbox = "GostR3411_94_TestParamSet"
+ sbox = "id-GostR3411-94-TestParamSet"
self.assertSequenceEqual(
cfb_encrypt(
key,
def test_gcl(self):
""" Test vectors from libgcl3
"""
- sbox = "Gost2814789_TestParamSet"
+ sbox = "id-Gost28147-89-TestParamSet"
key = hexdec(b"0475f6e05038fbfad2c7c390edb3ca3d1547124291ae1e8a2f79cd9ed2bcefbd")
plaintext = bytes(bytearray((
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
def test_gcl2(self):
""" Test vectors 2 from libgcl3
"""
- sbox = "Gost2814789_TestParamSet"
+ sbox = "id-Gost28147-89-TestParamSet"
key = hexdec(b"fc7ad2886f455b50d29008fa622b57d5c65b3c637202025799cadf0768519e8a")
plaintext = bytes(bytearray((
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
prv = bytes2long(prv)
signature = signature[32:] + signature[:32]
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_TestParamSet"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
pubX, pubY = public_key(c, prv)
self.assertSequenceEqual(long2bytes(pubX), pub_x)
self.assertSequenceEqual(long2bytes(pubY), pub_y)
self.assertTrue(verify(c, (pubX, pubY), digest, signature))
def test_sequence(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_TestParamSet"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
prv = bytes2long(urandom(32))
pubX, pubY = public_key(c, prv)
for _ in range(20):
self.assertTrue(verify(c, (pubX, pubY), digest, signature, mode=2012))
def test_sequence(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
prv = bytes2long(urandom(64))
pubX, pubY = public_key(c, prv)
for _ in range(20):
"""Test vectors for multiplication from :rfc:`8133`
"""
def test_curve1(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_CryptoPro_A_ParamSet"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-A-ParamSet"])
q_ind = (
0xA69D51CAF1A309FA9E9B66187759B0174C274E080356F23CFCBFE84D396AD7BB,
0x5D26F29ECC2E9AC0404DCF7986FA55FE94986362170F54B9616426A659786DAC,
)
def test_curve2(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_CryptoPro_B_ParamSet"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-B-ParamSet"])
q_ind = (
0x3D715A874A4B17CB3B517893A9794A2B36C89D2FFC693F01EE4CC27E7F49E399,
0x1C5A641FCF7CE7E87CDF8CEA38F3DB3096EACE2FAD158384B53953365F4FE7FE,
)
def test_curve3(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_CryptoPro_C_ParamSet"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-C-ParamSet"])
q_ind = (
0x1E36383E43BB6CFA2917167D71B7B5DD3D6D462B43D7C64282AE67DFBEC2559D,
0x137478A9F721C73932EA06B45CF72E37EB78A63F29A542E563C614650C8B6399,
)
def test_curve4(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
q_ind = (
0x2A17F8833A32795327478871B5C5E88AEFB91126C64B4B8327289BEA62559425D18198F133F400874328B220C74497CD240586CB249E158532CB8090776CD61C,
0x728F0C4A73B48DA41CE928358FAD26B47A6E094E9362BAE82559F83CDDC4EC3A4676BD3707EDEAF4CD85E99695C64C241EDC622BE87DC0CF87F51F4367F723C5,
)
def test_curve5(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetB"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetB"])
q_ind = (
0x7E1FAE8285E035BEC244BEF2D0E5EBF436633CF50E55231DEA9C9CF21D4C8C33DF85D4305DE92971F0A4B4C07E00D87BDBC720EB66E49079285AAF12E0171149,
0x2CC89998B875D4463805BA0D858A196592DB20AB161558FF2F4EF7A85725D20953967AE621AFDEAE89BB77C83A2528EF6FCE02F68BDA4679D7F2704947DBC408,
)
def test_curve6(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_256_ParamSetA"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-2012-256-paramSetA"])
q_ind = (
0xB51ADF93A40AB15792164FAD3352F95B66369EB2A4EF5EFAE32829320363350E,
0x74A358CC08593612F5955D249C96AFB7E8B0BB6D8BD2BBE491046650D822BE18,
)
def test_curve7(self):
- c = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetC"])
+ c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-2012-512-paramSetC"])
q_ind = (
0x489C91784E02E98F19A803ABCA319917F37689E5A18965251CE2FF4E8D8B298F5BA7470F9E0E713487F96F4A8397B3D09A270C9D367EB5E0E6561ADEEB51581D,
0x684EA885ACA64EAF1B3FEE36C0852A3BE3BD8011B0EF18E203FF87028D6EB5DB2C144A0DCC71276542BFD72CA2A43FA4F4939DA66D9A60793C704A8C94E16F18,
class TestVKO34102001(TestCase):
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_TestParamSet"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
ukm = ukm_unmarshal(hexdec("5172be25f852a233"))
prv1 = prv_unmarshal(hexdec("1df129e43dab345b68f6a852f4162dc69f36b2f84717d08755cc5c44150bf928"))
prv2 = prv_unmarshal(hexdec("5b9356c6474f913f1e83885ea0edd5df1a43fd9d799d219093241157ac9ed473"))
self.assertSequenceEqual(kek_34102001(curve, prv2, pub1, ukm), kek)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2001_TestParamSet"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
"""RFC 7836
"""
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
ukm = ukm_unmarshal(hexdec("1d80603c8544c727"))
prvA = prv_unmarshal(hexdec("c990ecd972fce84ec4db022778f50fcac726f46708384b8d458304962d7147f8c2db41cef22c90b102f2968404f9b9be6d47c79692d81826b32b8daca43cb667"))
pubA = pub_unmarshal(hexdec("aab0eda4abff21208d18799fb9a8556654ba783070eba10cb9abb253ec56dcf5d3ccba6192e464e6e5bcb6dea137792f2431f6c897eb1b3c0cc14327b1adc0a7914613a3074e363aedb204d38d3563971bd8758e878c9db11403721b48002d38461f92472d40ea92f9958c0ffa4c93756401b97f89fdbe0b5e46e4a4631cdb5a"), mode=2012)
self.assertSequenceEqual(kek_34102012256(curve, prvB, pubA, ukm), vko)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
"""RFC 7836
"""
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
ukm = ukm_unmarshal(hexdec("1d80603c8544c727"))
prvA = prv_unmarshal(hexdec("c990ecd972fce84ec4db022778f50fcac726f46708384b8d458304962d7147f8c2db41cef22c90b102f2968404f9b9be6d47c79692d81826b32b8daca43cb667"))
pubA = pub_unmarshal(hexdec("aab0eda4abff21208d18799fb9a8556654ba783070eba10cb9abb253ec56dcf5d3ccba6192e464e6e5bcb6dea137792f2431f6c897eb1b3c0cc14327b1adc0a7914613a3074e363aedb204d38d3563971bd8758e878c9db11403721b48002d38461f92472d40ea92f9958c0ffa4c93756401b97f89fdbe0b5e46e4a4631cdb5a"), mode=2012)
self.assertSequenceEqual(kek_34102012512(curve, prvB, pubA, ukm), vko)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+ curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
class TestVectors(TestCase):
def test_empty(self):
self.assertSequenceEqual(
- GOST341194(b"", "GostR3411_94_TestParamSet").hexdigest(),
+ GOST341194(b"", "id-GostR3411-94-TestParamSet").hexdigest(),
"ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d",
)
def test_a(self):
self.assertSequenceEqual(
- GOST341194(b"a", "GostR3411_94_TestParamSet").hexdigest(),
+ GOST341194(b"a", "id-GostR3411-94-TestParamSet").hexdigest(),
"d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd",
)
def test_abc(self):
self.assertSequenceEqual(
- GOST341194(b"abc", "GostR3411_94_TestParamSet").hexdigest(),
+ GOST341194(b"abc", "id-GostR3411-94-TestParamSet").hexdigest(),
"f3134348c44fb1b2a277729e2285ebb5cb5e0f29c975bc753b70497c06a4d51d",
)
def test_message_digest(self):
self.assertSequenceEqual(
- GOST341194(b"message digest", "GostR3411_94_TestParamSet").hexdigest(),
+ GOST341194(b"message digest", "id-GostR3411-94-TestParamSet").hexdigest(),
"ad4434ecb18f2c99b60cbe59ec3d2469582b65273f48de72db2fde16a4889a4d",
)
def test_Us(self):
self.assertSequenceEqual(
- GOST341194(128 * b"U", "GostR3411_94_TestParamSet").hexdigest(),
+ GOST341194(128 * b"U", "id-GostR3411-94-TestParamSet").hexdigest(),
"53a3a3ed25180cef0c1d85a074273e551c25660a87062a52d926a9e8fe5733a4",
)
def test_dog(self):
self.assertSequenceEqual(
- GOST341194(b"The quick brown fox jumps over the lazy dog", "GostR3411_94_TestParamSet",).hexdigest(),
+ GOST341194(b"The quick brown fox jumps over the lazy dog", "id-GostR3411-94-TestParamSet",).hexdigest(),
"77b7fa410c9ac58a25f49bca7d0468c9296529315eaca76bd1a10f376d1f4294",
)
def test_cog(self):
self.assertSequenceEqual(
- GOST341194(b"The quick brown fox jumps over the lazy cog", "GostR3411_94_TestParamSet",).hexdigest(),
+ GOST341194(b"The quick brown fox jumps over the lazy cog", "id-GostR3411-94-TestParamSet",).hexdigest(),
"a3ebc4daaab78b0be131dab5737a7f67e602670d543521319150d2e14eeec445",
)
def test_rfc32(self):
self.assertSequenceEqual(
- GOST341194(b"This is message, length=32 bytes", "GostR3411_94_TestParamSet",).hexdigest(),
+ GOST341194(b"This is message, length=32 bytes", "id-GostR3411-94-TestParamSet",).hexdigest(),
"b1c466d37519b82e8319819ff32595e047a28cb6f83eff1c6916a815a637fffa",
)
def test_rfc50(self):
self.assertSequenceEqual(
- GOST341194(b"Suppose the original message has length = 50 bytes", "GostR3411_94_TestParamSet",).hexdigest(),
+ GOST341194(b"Suppose the original message has length = 50 bytes", "id-GostR3411-94-TestParamSet",).hexdigest(),
"471aba57a60a770d3a76130635c1fbea4ef14de51f78b4ae57dd893b62f55208",
)
"""
def test_empty(self):
self.assertSequenceEqual(
- GOST341194(b"", "GostR3411_94_CryptoProParamSet").hexdigest(),
+ GOST341194(b"", "id-GostR3411-94-CryptoProParamSet").hexdigest(),
"981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0",
)
def test_a(self):
self.assertSequenceEqual(
- GOST341194(b"a", "GostR3411_94_CryptoProParamSet").hexdigest(),
+ GOST341194(b"a", "id-GostR3411-94-CryptoProParamSet").hexdigest(),
"e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011",
)
def test_abc(self):
self.assertSequenceEqual(
- GOST341194(b"abc", "GostR3411_94_CryptoProParamSet").hexdigest(),
+ GOST341194(b"abc", "id-GostR3411-94-CryptoProParamSet").hexdigest(),
"b285056dbf18d7392d7677369524dd14747459ed8143997e163b2986f92fd42c",
)
def test_message_digest(self):
self.assertSequenceEqual(
- GOST341194(b"message digest", "GostR3411_94_CryptoProParamSet",).hexdigest(),
+ GOST341194(b"message digest", "id-GostR3411-94-CryptoProParamSet",).hexdigest(),
"bc6041dd2aa401ebfa6e9886734174febdb4729aa972d60f549ac39b29721ba0",
)
def test_dog(self):
self.assertSequenceEqual(
- GOST341194(b"The quick brown fox jumps over the lazy dog", "GostR3411_94_CryptoProParamSet",).hexdigest(),
+ GOST341194(b"The quick brown fox jumps over the lazy dog", "id-GostR3411-94-CryptoProParamSet",).hexdigest(),
"9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76",
)
def test_32(self):
self.assertSequenceEqual(
- GOST341194(b"This is message, length=32 bytes", "GostR3411_94_CryptoProParamSet",).hexdigest(),
+ GOST341194(b"This is message, length=32 bytes", "id-GostR3411-94-CryptoProParamSet",).hexdigest(),
"2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb",
)
def test_50(self):
self.assertSequenceEqual(
- GOST341194(b"Suppose the original message has length = 50 bytes", "GostR3411_94_CryptoProParamSet",).hexdigest(),
+ GOST341194(b"Suppose the original message has length = 50 bytes", "id-GostR3411-94-CryptoProParamSet",).hexdigest(),
"c3730c5cbccacf915ac292676f21e8bd4ef75331d9405e5f1a61dc3130a65011",
)
def test_Us(self):
self.assertSequenceEqual(
- GOST341194(128 * b"U", "GostR3411_94_CryptoProParamSet").hexdigest(),
+ GOST341194(128 * b"U", "id-GostR3411-94-CryptoProParamSet").hexdigest(),
"1c4ac7614691bbf427fa2316216be8f10d92edfd37cd1027514c1008f649c4e8",
)
key,
bytes(shrouded_key_bag["encryptedData"]),
iv=bytes(enc_scheme_params["iv"]),
- sbox="Gost28147_tc26_ParamZ",
+ sbox="id-tc26-gost-28147-param-Z",
),
private_key_info_expected,
)
key,
bytes(encrypted_data["encryptedContentInfo"]["encryptedContent"]),
iv=bytes(enc_scheme_params["iv"]),
- sbox="Gost28147_tc26_ParamZ",
+ sbox="id-tc26-gost-28147-param-Z",
),
cert_bag_expected,
)
""")
prv_key_raw = hexdec("BFCF1D623E5CDD3032A7C6EABB4A923C46E43D640FFEAAF2C3ED39A8FA399924")[::-1]
self.process_cert(
- "GostR3410_2001_CryptoPro_XchA_ParamSet",
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
2001,
GOST34112012256,
prv_key_raw,
""")
prv_key_raw = hexdec("3FC01CDCD4EC5F972EB482774C41E66DB7F380528DFE9E67992BA05AEE462435757530E641077CE587B976C8EEB48C48FD33FD175F0C7DE6A44E014E6BCB074B")[::-1]
self.process_cert(
- "GostR3410_2012_TC26_ParamSetB",
+ "id-tc26-gost-3410-12-512-paramSetB",
2012,
GOST34112012512,
prv_key_raw,
@verbatim
>>> from pygost.gost3410 import CURVE_PARAMS
>>> from pygost.gost3410 import GOST3410Curve
->>> curve = GOST3410Curve(*CURVE_PARAMS["GostR3410_2012_TC26_ParamSetA"])
+>>> curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
>>> from os import urandom
>>> prv_raw = urandom(32)
>>> from pygost.gost3410 import prv_unmarshal