|
| 1 | +# See FinTS_3.0_Security_Sicherheitsverfahren_HBCI_Rel_20130718_final_version.pdf |
| 2 | +import time |
| 3 | +from collections import OrderedDict |
| 4 | + |
| 5 | +from . import FinTS3Segment |
| 6 | + |
| 7 | + |
| 8 | +# See B.5.3 |
| 9 | +# Currently PINTAN only |
| 10 | +class FinTS3CryptoHeader(FinTS3Segment): |
| 11 | + def __init__(self, customer=None, blz=None): |
| 12 | + self.elements = OrderedDict([ |
| 13 | + ('head', OrderedDict([ |
| 14 | + ('identifier', 'HNVSK'), |
| 15 | + ('counter', 998), # See B.8 |
| 16 | + ('version', 3) |
| 17 | + ])), |
| 18 | + ('profile', OrderedDict([ |
| 19 | + ('mode', 'PIN'), |
| 20 | + ('version', 1) |
| 21 | + ])), |
| 22 | + ('function', 998), # kinda magic, but this is according to the example E.3.1 |
| 23 | + ('role', '1'), |
| 24 | + ('identification', OrderedDict([ |
| 25 | + ('identifier', 1), |
| 26 | + ('cid', ''), # according to the documentation we can ignore this |
| 27 | + ('part', 0) # according to the documentation we can ignore this |
| 28 | + ])), |
| 29 | + ('datetime', OrderedDict([ |
| 30 | + ('identifier', 1), # Sicherheitszeitstempel |
| 31 | + ('date', time.strftime('%Y%m%d')), # YYYYMMDD |
| 32 | + ('time', time.strftime('%H%M%S')) # HHMMSS |
| 33 | + ])), |
| 34 | + # p. 191 |
| 35 | + ('encryption', OrderedDict([ |
| 36 | + ('usage', 2), # Owner Symmetric (OSY) |
| 37 | + ('mode', 2), # Cipher Block Chaining (CBC) |
| 38 | + ('algorithm', 13), # 2-Key-Triple-DES |
| 39 | + ('algparams', b'NOKEY'), # Do we care? |
| 40 | + ('algkeyidentifier', 6), # Must be right, according to aqBanking! |
| 41 | + ('algparamidentifier', 1) # Only possible value --> Clear text (IVC) |
| 42 | + ])), |
| 43 | + # p. 184 |
| 44 | + ('keyname', OrderedDict([ |
| 45 | + ('foo', 280), |
| 46 | + ('bank', blz), # so-called Bankleitzahl |
| 47 | + ('customer', customer), # Username, in Germany often the account number |
| 48 | + ('keytype', 'V'), # Chiffrierschlüssel |
| 49 | + ('keynumber', 1), |
| 50 | + ('keyversion', 1) |
| 51 | + ])), |
| 52 | + ('compression', 0) # No compression |
| 53 | + ]) |
| 54 | + |
| 55 | + |
| 56 | +# See B.5.4 |
| 57 | +class FinTS3CryptoBody(FinTS3Segment): |
| 58 | + def __init__(self, data=None): |
| 59 | + self.elements = OrderedDict([ |
| 60 | + ('head', OrderedDict([ |
| 61 | + ('identifier', 'HNVSD'), |
| 62 | + ('counter', 999), # See B.8 |
| 63 | + ('version', 1) |
| 64 | + ])), |
| 65 | + ('data', b'') |
| 66 | + ]) |
| 67 | + |
| 68 | + def set_data(self, data): |
| 69 | + self.elements['data'] = bytes(data, 'ISO-8859-2') |
| 70 | + |
| 71 | + def get_data(self, data): |
| 72 | + return self.elements['data'] |
| 73 | + |
| 74 | +# See B.5.1 |
| 75 | +# class FinTS3SignatureHeader(FinTS3Segment): |
0 commit comments