Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: keyfile with multiline text in Key/Data #337

Closed
hpierre001 opened this issue Apr 3, 2023 · 4 comments
Closed

Bug: keyfile with multiline text in Key/Data #337

hpierre001 opened this issue Apr 3, 2023 · 4 comments

Comments

@hpierre001
Copy link

hpierre001 commented Apr 3, 2023

When the key data is on multiple lines, parsing it with lxml 4.9.1 in a linux environnement, lets newline and tab in the middle which can't be striped by strip, leading to an error with bytes.fromhex (line 129 of pykeepass/common.py).

PS: the error doesn't occur on windows with lxml 4.9.2

@Evidlo
Copy link
Member

Evidlo commented May 21, 2023

Can you paste an example key file which causes the error? I'm not able to reproduce this on Linux:

>>> lxml.__version__
'4.9.1'

>>> from pykeepass import PyKeePass; kp = PyKeePass('test3.kdbx', 'password', '/tmp/test3_test.key')

>>> !cat /tmp/test3_test.key
<?xml version="1.0" encoding="utf-8"?>
<KeyFile>
	<Meta>
		<Version>1.00</Version>
	</Meta>
	<Key>
		<Data>Qp9MrFM1RpSLO8iHZHGAiP
		br8Z+hDFpp0cgtH+RM0hw=</Data>
	</Key>
</KeyFile>

@hpierre001
Copy link
Author

It was one produced on windows and then used on Linux so it must be due to the use by windows of "\r\n" as a new line character instead of "\n"

@Evidlo
Copy link
Member

Evidlo commented Sep 13, 2023

test3.key in this repo already has DOS line endings, so that can't be it.

[evan@blackbox tests] od -bc test3.key 
0000000 074 077 170 155 154 040 166 145 162 163 151 157 156 075 042 061
          <   ?   x   m   l       v   e   r   s   i   o   n   =   "   1
0000020 056 060 042 040 145 156 143 157 144 151 156 147 075 042 165 164
          .   0   "       e   n   c   o   d   i   n   g   =   "   u   t
0000040 146 055 070 042 077 076 015 012 074 113 145 171 106 151 154 145
          f   -   8   "   ?   >  \r  \n   <   K   e   y   F   i   l   e
0000060 076 015 012 011 074 115 145 164 141 076 015 012 011 011 074 126
          >  \r  \n  \t   <   M   e   t   a   >  \r  \n  \t  \t   <   V
0000100 145 162 163 151 157 156 076 061 056 060 060 074 057 126 145 162
          e   r   s   i   o   n   >   1   .   0   0   <   /   V   e   r
0000120 163 151 157 156 076 015 012 011 074 057 115 145 164 141 076 015
          s   i   o   n   >  \r  \n  \t   <   /   M   e   t   a   >  \r
0000140 012 011 074 113 145 171 076 015 012 011 011 074 104 141 164 141
         \n  \t   <   K   e   y   >  \r  \n  \t  \t   <   D   a   t   a
0000160 076 121 160 071 115 162 106 115 061 122 160 123 114 117 070 151
          >   Q   p   9   M   r   F   M   1   R   p   S   L   O   8   i
0000200 110 132 110 107 101 151 120 142 162 070 132 053 150 104 106 160
          H   Z   H   G   A   i   P   b   r   8   Z   +   h   D   F   p
0000220 160 060 143 147 164 110 053 122 115 060 150 167 075 074 057 104
          p   0   c   g   t   H   +   R   M   0   h   w   =   <   /   D
0000240 141 164 141 076 015 012 011 074 057 113 145 171 076 015 012 074
          a   t   a   >  \r  \n  \t   <   /   K   e   y   >  \r  \n   <
0000260 057 113 145 171 106 151 154 145 076 015 012
          /   K   e   y   F   i   l   e   >  \r  \n
0000273

Is there a keyfile that I can reproduce this issue with?

@Evidlo
Copy link
Member

Evidlo commented May 17, 2024

I'll assume this is resolved for now.

@Evidlo Evidlo closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants