<div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">BTW, i am using `<span style="color:rgb(0,0,0);font-size:12px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">CKM_RSA_PKCS</span>` because it's the only one of the suggested mechanisms that SoftHSM supports according to the output of `pkcs11-tool --module libsofthsm2.so ---slot $slot --list-mechanisms`.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><i>$ <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">pkcs11-tool --module libsofthsm2.so ---slot $slot --list-mechanisms</span></i></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><i>...</i></div><div class="gmail_default"><i><font face="trebuchet ms, sans-serif">RSA-PKCS, keySize={512,16384}, encrypt, decrypt, sign, verify, wrap, unwrap</font><br></i></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"><i>...</i></font></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br><font face="trebuchet ms, sans-serif">Cheers,<br>Lingxian Kong</font></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Jul 11, 2018 at 10:48 PM, Lingxian Kong <span dir="ltr"><<a href="mailto:anlin.kong@gmail.com" target="_blank">anlin.kong@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Hi Ade,</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Thanks for your reply.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I just replaced `CKM_AES_CBC_PAD` with `CKM_RSA_PKCS` here[1], of course I defined `CKM_RSA_PKCS = 0x00000001` in the code, but still got the following error:</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><div class="gmail_default"><i>Jul 11 10:42:05 barbican-devstack devstack@barbican-svc.service[<wbr>19897]: 2018-07-11 10:42:05.309 19900 WARNING barbican.plugin.crypto.p11_<wbr>crypto [req-f2d27105-4811-4c77-a321-<wbr>2ac1399cc9d2 b268f84aef814ae</i></div><div class="gmail_default"><i>da17ad3fa38e0049d 7abe0e02baec4df2b6046d7ef7f449<wbr>98 - default default] Reinitializing PKCS#11 library: HSM returned response code: 0x7L CKR_ARGUMENTS_BAD: P11CryptoPluginException: HSM returned response code: 0x7L CKR_ARGUMENTS_BAD</i></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">​[1]: <a href="https://github.com/openstack/barbican/blob/5dea5cec130b59ecfb8d46435cd7eb3212894b4c/barbican/plugin/crypto/pkcs11.py#L496" target="_blank">https://github.com/openstack/<wbr>barbican/blob/<wbr>5dea5cec130b59ecfb8d46435cd7eb<wbr>3212894b4c/barbican/plugin/<wbr>crypto/pkcs11.py#L496</a>​</div><br clear="all"><div><div class="m_8664224084236421903gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br><font face="trebuchet ms, sans-serif">Cheers,<br>Lingxian Kong</font></div></div></div></div></div></div></div></div></div></div></div></div></div></div><span class="">
<br><div class="gmail_quote">On Wed, Jul 11, 2018 at 9:18 PM, Ade Lee <span dir="ltr"><<a href="mailto:alee@redhat.com" target="_blank">alee@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Lingxian, <br>
<br>
I don't see any reason not to provide support for other wrapping<br>
mechanisms.<br>
<br>
Have you tried hacking the code to use one of the other wrapping<br>
mechanisms to see if it works?  Ultimately, what is passed are<br>
parameters to CFFI.  As long as you pass in the right input and your<br>
PKCS#11 library can support it, then there should be no problem.<br>
<br>
If it works, it makes sense to make the wrapping algorithm configurable<br>
for the plugin.  <br>
<br>
It may or may not make sense to store the wrapping algorithm used in<br>
the secret plugin-metadata if we want to support migration to other<br>
HSMs.<br>
<br>
Ade </blockquote></div></span></div></div>
</blockquote></div><br></div>