Discussion:
[xmlsec] Thoughts on a new mscng backend
Miklos Vajna
2018-01-04 21:50:59 UTC
Permalink
Hi,

When I was working on ECDSA support for the NSS backend, I noticed that
the mscrypto backend can't have the same support, as Microsoft is not
adding that feature to its CryptoAPI, which seems to be deprecated today
[1].

As far as I see the replacement is the CNG API [2], which has relatively
good documentation, so doing similar things with CNG (compared to
CryptoAPI) sounds doable.

Adding CNG support as part of the existing mscrypto backend sounds quite
problematic, though -- since most of that backend is CryptoAPI calls,
while the point would be eliminating those.

So perhaps the best way forward would be a new backend (let's name it
"mscng" e.g.), even if that would mean a little duplication (e.g.
CryptAcquireCertificatePrivateKey() is needed in both contexts,
depending on arguments it either returns a CNG NCRYPT_KEY_HANDLE or a
CryptoAPI HCRYPTPROV). That way also the new backend would be "clean"
from wincrypt.h (and similarly mscrypto would be not polluted by
ncrypt.h and so on).

Does this sounds like a good direction to go? My hope would be that even
with my limited free time I could implement an initial mscng backend
that has one working use-case (e.g. ecdsa/sha256 dsig verification,
something not supported by mscrypto), get that reviewed, and once that
looks good, we can iterate from there. And once (long-term) it's on par
with the mscrypto backend feature-wise, it can be discussed what to do
with the mscrypto backend. But that's a lot of work of course.

I'm asking if adding CNG support in the form of a new mscng backend is
OK as I would like to avoid writing the boilerplate code for a new
backend if that is seen as the wrong approach anyway. :-)

Thanks,

Miklos

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380252(v=vs.85).aspx
[2] https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx
Aleksey Sanin
2018-01-04 23:24:51 UTC
Permalink
That sounds like a great plan! I would recommend to use the
skeleton folder to start. I should be able to get my hands
on Windows box and help out as well.

Aleksey
Post by Miklos Vajna
Hi,
When I was working on ECDSA support for the NSS backend, I noticed that
the mscrypto backend can't have the same support, as Microsoft is not
adding that feature to its CryptoAPI, which seems to be deprecated today
[1].
As far as I see the replacement is the CNG API [2], which has relatively
good documentation, so doing similar things with CNG (compared to
CryptoAPI) sounds doable.
Adding CNG support as part of the existing mscrypto backend sounds quite
problematic, though -- since most of that backend is CryptoAPI calls,
while the point would be eliminating those.
So perhaps the best way forward would be a new backend (let's name it
"mscng" e.g.), even if that would mean a little duplication (e.g.
CryptAcquireCertificatePrivateKey() is needed in both contexts,
depending on arguments it either returns a CNG NCRYPT_KEY_HANDLE or a
CryptoAPI HCRYPTPROV). That way also the new backend would be "clean"
from wincrypt.h (and similarly mscrypto would be not polluted by
ncrypt.h and so on).
Does this sounds like a good direction to go? My hope would be that even
with my limited free time I could implement an initial mscng backend
that has one working use-case (e.g. ecdsa/sha256 dsig verification,
something not supported by mscrypto), get that reviewed, and once that
looks good, we can iterate from there. And once (long-term) it's on par
with the mscrypto backend feature-wise, it can be discussed what to do
with the mscrypto backend. But that's a lot of work of course.
I'm asking if adding CNG support in the form of a new mscng backend is
OK as I would like to avoid writing the boilerplate code for a new
backend if that is seen as the wrong approach anyway. :-)
Thanks,
Miklos
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380252(v=vs.85).aspx
[2] https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
Miklos Vajna
2018-05-04 15:33:58 UTC
Permalink
Hi,
Post by Aleksey Sanin
That sounds like a great plan! I would recommend to use the
skeleton folder to start.
Thanks for all the reviews, current master looks reasonable to me when I
compare 'make check' output of the mscrypto and mscng backends:

- 0 tests pass only on mscrypto
- 126 tests pass on both mscrypto and mscng
- 3 tests pass only on mscng (ecdsa signing with sha1/256/512)

I wonder what else is missing so it could be claimed that the mscng
backend is more or less a drop-in replacement for the mscrypto one.
There are two things I can think of:

- mscrypto supports reading your OS-level certificates and use that
during e.g. signing.

- There are a few functions which are part of the mscrypto public API
(e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is no mscng
equivalent yet. Those are probably interesting as e.g. LibreOffice
uses those functions.

I plan to get to these two in the next few weeks. But is there anything
else larger missing?

Thanks,

Miklos
Aleksey Sanin
2018-05-05 02:08:34 UTC
Permalink
Thanks for all the code you've wrote!

I think the only area missing is GOST algorithms support. It
requires special configs/dlls on Windows so I don't know if
it is even available for MSCNG. May be someone on the list
has direct knowledge and can chime in?

I was planning to ask you what would be the right time to do
an xmlsec release. Sounds like in a couple weeks is the right
timeline. I think it would be great to have others play with
mscng to find out any issues. But otherwise, it looks great!

Aleksey
Post by Miklos Vajna
Hi,
Post by Aleksey Sanin
That sounds like a great plan! I would recommend to use the
skeleton folder to start.
Thanks for all the reviews, current master looks reasonable to me when I
- 0 tests pass only on mscrypto
- 126 tests pass on both mscrypto and mscng
- 3 tests pass only on mscng (ecdsa signing with sha1/256/512)
I wonder what else is missing so it could be claimed that the mscng
backend is more or less a drop-in replacement for the mscrypto one.
- mscrypto supports reading your OS-level certificates and use that
during e.g. signing.
- There are a few functions which are part of the mscrypto public API
(e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is no mscng
equivalent yet. Those are probably interesting as e.g. LibreOffice
uses those functions.
I plan to get to these two in the next few weeks. But is there anything
else larger missing?
Thanks,
Miklos
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
Dmitry Belyavsky
2018-05-07 07:23:43 UTC
Permalink
I'll ask whether there is any CNG-based GOST implementation.
Post by Aleksey Sanin
Thanks for all the code you've wrote!
I think the only area missing is GOST algorithms support. It
requires special configs/dlls on Windows so I don't know if
it is even available for MSCNG. May be someone on the list
has direct knowledge and can chime in?
I was planning to ask you what would be the right time to do
an xmlsec release. Sounds like in a couple weeks is the right
timeline. I think it would be great to have others play with
mscng to find out any issues. But otherwise, it looks great!
Aleksey
Hi,
On Thu, Jan 04, 2018 at 03:24:51PM -0800, Aleksey Sanin <
Post by Aleksey Sanin
That sounds like a great plan! I would recommend to use the
skeleton folder to start.
Thanks for all the reviews, current master looks reasonable to me when I
- 0 tests pass only on mscrypto
- 126 tests pass on both mscrypto and mscng
- 3 tests pass only on mscng (ecdsa signing with sha1/256/512)
I wonder what else is missing so it could be claimed that the mscng
backend is more or less a drop-in replacement for the mscrypto one.
- mscrypto supports reading your OS-level certificates and use that
during e.g. signing.
- There are a few functions which are part of the mscrypto public API
(e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is no mscng
equivalent yet. Those are probably interesting as e.g. LibreOffice
uses those functions.
I plan to get to these two in the next few weeks. But is there anything
else larger missing?
Thanks,
Miklos
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
--
SY, Dmitry Belyavsky
Aleksey Sanin
2018-05-07 16:59:43 UTC
Permalink
Thank you!

Aleksey
Post by Dmitry Belyavsky
I'll ask whether there is any CNG-based GOST implementation.
Thanks for all the code you've wrote!
I think the only area missing is GOST algorithms support. It
requires special configs/dlls on Windows so I don't know if
it is even available for MSCNG. May be someone on the list
has direct knowledge and can chime in?
I was planning to ask you what would be the right time to do
an xmlsec release. Sounds like in a couple weeks is the right
timeline. I think it would be great to have others play with
mscng to find out any issues. But otherwise, it looks great!
Aleksey
Hi,
On Thu, Jan 04, 2018 at 03:24:51PM -0800, Aleksey Sanin
Post by Aleksey Sanin
That sounds like a great plan! I would recommend to use the
skeleton folder to start.
Thanks for all the reviews, current master looks reasonable to me
when I
- 0 tests pass only on mscrypto
- 126 tests pass on both mscrypto and mscng
- 3 tests pass only on mscng (ecdsa signing with sha1/256/512)
I wonder what else is missing so it could be claimed that the mscng
backend is more or less a drop-in replacement for the mscrypto one.
- mscrypto supports reading your OS-level certificates and use that
   during e.g. signing.
- There are a few functions which are part of the mscrypto public API
   (e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is no mscng
   equivalent yet. Those are probably interesting as e.g. LibreOffice
   uses those functions.
I plan to get to these two in the next few weeks. But is there
anything
else larger missing?
Thanks,
Miklos
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
--
SY, Dmitry Belyavsky
Dmitry Belyavsky
2018-05-09 13:30:02 UTC
Permalink
No, there is no GOST CNG-based backend.
Post by Aleksey Sanin
Thank you!
Aleksey
Post by Dmitry Belyavsky
I'll ask whether there is any CNG-based GOST implementation.
Thanks for all the code you've wrote!
I think the only area missing is GOST algorithms support. It
requires special configs/dlls on Windows so I don't know if
it is even available for MSCNG. May be someone on the list
has direct knowledge and can chime in?
I was planning to ask you what would be the right time to do
an xmlsec release. Sounds like in a couple weeks is the right
timeline. I think it would be great to have others play with
mscng to find out any issues. But otherwise, it looks great!
Aleksey
Hi,
On Thu, Jan 04, 2018 at 03:24:51PM -0800, Aleksey Sanin
Post by Aleksey Sanin
That sounds like a great plan! I would recommend to use the
skeleton folder to start.
Thanks for all the reviews, current master looks reasonable to me
when I
- 0 tests pass only on mscrypto
- 126 tests pass on both mscrypto and mscng
- 3 tests pass only on mscng (ecdsa signing with sha1/256/512)
I wonder what else is missing so it could be claimed that the mscng
backend is more or less a drop-in replacement for the mscrypto one.
- mscrypto supports reading your OS-level certificates and use that
during e.g. signing.
- There are a few functions which are part of the mscrypto public
API
Post by Dmitry Belyavsky
(e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is no
mscng
Post by Dmitry Belyavsky
equivalent yet. Those are probably interesting as e.g.
LibreOffice
Post by Dmitry Belyavsky
uses those functions.
I plan to get to these two in the next few weeks. But is there
anything
else larger missing?
Thanks,
Miklos
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
_______________________________________________
xmlsec mailing list
http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
--
SY, Dmitry Belyavsky
--
SY, Dmitry Belyavsky
Aleksey Sanin
2018-05-09 17:21:45 UTC
Permalink
Thanks for checking!

Aleksey
Post by Dmitry Belyavsky
No, there is no GOST CNG-based backend.
Thank you!
Aleksey
Post by Dmitry Belyavsky
I'll ask whether there is any CNG-based GOST implementation.
     Thanks for all the code you've wrote!
     I think the only area missing is GOST algorithms support. It
     requires special configs/dlls on Windows so I don't know if
     it is even available for MSCNG. May be someone on the list
     has direct knowledge and can chime in?
     I was planning to ask you what would be the right time to do
     an xmlsec release. Sounds like in a couple weeks is the right
     timeline. I think it would be great to have others play with
     mscng to find out any issues. But otherwise, it looks great!
     Aleksey
     > Hi,
     >
     > On Thu, Jan 04, 2018 at 03:24:51PM -0800, Aleksey Sanin
     >> That sounds like a great plan! I would recommend to use the
     >> skeleton folder to start.
     >
     > Thanks for all the reviews, current master looks reasonable
to me
Post by Dmitry Belyavsky
     when I
     >
     > - 0 tests pass only on mscrypto
     > - 126 tests pass on both mscrypto and mscng
     > - 3 tests pass only on mscng (ecdsa signing with sha1/256/512)
     >
     > I wonder what else is missing so it could be claimed that
the mscng
Post by Dmitry Belyavsky
     > backend is more or less a drop-in replacement for the
mscrypto one.
Post by Dmitry Belyavsky
     >
     > - mscrypto supports reading your OS-level certificates and
use that
Post by Dmitry Belyavsky
     >   during e.g. signing.
     >
     > - There are a few functions which are part of the mscrypto
public API
Post by Dmitry Belyavsky
     >   (e.g. xmlSecMSCryptoX509StoreAdoptKeyStore()) and there is
no mscng
Post by Dmitry Belyavsky
     >   equivalent yet. Those are probably interesting as e.g.
LibreOffice
Post by Dmitry Belyavsky
     >   uses those functions.
     >
     > I plan to get to these two in the next few weeks. But is there
     anything
     > else larger missing?
     >
     > Thanks,
     >
     > Miklos
     >
     >
     >
     > _______________________________________________
     > xmlsec mailing list
     > http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
Post by Dmitry Belyavsky
     <http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>>
Post by Dmitry Belyavsky
     >
     _______________________________________________
     xmlsec mailing list
     http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>
Post by Dmitry Belyavsky
     <http://www.aleksey.com/mailman/listinfo/xmlsec
<http://www.aleksey.com/mailman/listinfo/xmlsec>>
Post by Dmitry Belyavsky
--
SY, Dmitry Belyavsky
--
SY, Dmitry Belyavsky
Miklos Vajna
2018-05-09 07:22:54 UTC
Permalink
Hi,
I wonder if it is better to do it in the tests/ and just add
explanation on how to manually test into the README. But examples
is fine as well (just add a couple sentences to README file there
about it).
Aha OK, I'll add the sample template to tests/ with a README in my next
pull request.

Regards,

Miklos

Loading...