<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:Arial;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>All,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am trying to get the tls_schannel.c module to work with a
DeviceScape supplicant build. The network requires a client certificate, which
I have in PFX form. The first thing I noticed about the code is that there
doesn&#8217;t seem to be any support for client certificates (I found the
header comment &#8220;</span></font><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";font-weight:bold'>TODO: add
support for EAP-TLS (client cert/key conf</span></font></b><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>&#8221; as well ! )<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Anyway, I added some code to use PFXImportCertStore to get
the certificate credential handle, but when I try to use the credential with
InitializeSecurityContext, I actually get a ARM processor exception (Misaligned
Datatype). Other CryptoAPI calls I make on this credential handle seem to work
OK.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Now the exception might be a side effect of something else I
am doing wrong, but my real question is, does anybody on here have any
experience with CryptoAPI and using client certificates on WinCE that might be
able to help?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Here is a code fragment of the steps I am taking (var types
and error handling omitted for clarity):<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // first open the PFX file<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; hPemFile =
CreateFile(pfxFilename, &#8230;);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; pfxBufLength =
GetFileSize(hPemFile,NULL);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // allocate a buffer to hold the
file content<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; pfxBuf = (unsigned
char*)malloc(pfxBufLength);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // read the content to the buffer<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; ReadFile(hPemFile, pfxBuf,
pfxBufLength, &amp;bytesRead, NULL);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // now proceed to import PFX
content<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; certBlob.pbData = pfxBuf;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; certBlob.cbData = pfxBufLength;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // Create temporary store<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; hCertStore1 =
PFXImportCertStore(&amp;certBlob, passwordW, CRYPT_EXPORTABLE);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // Get the certificate context<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; pCertContext =
CertEnumCertificatesInStore(hCertStore1, pCertContext);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; // try to use this certificate<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
memset(&amp;conn-&gt;schannel_cred, 0, sizeof(conn-&gt;schannel_cred));<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; conn-&gt;schannel_cred.dwVersion
= SCHANNEL_CRED_VERSION;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
conn-&gt;schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; algs[0] = CALG_RSA_KEYX;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
conn-&gt;schannel_cred.cSupportedAlgs = 1;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
conn-&gt;schannel_cred.palgSupportedAlgs = algs;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; conn-&gt;schannel_cred.dwFlags |=
SCH_CRED_NO_DEFAULT_CREDS;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
conn-&gt;schannel_cred.cCreds&nbsp;&nbsp;&nbsp;&nbsp; = 1;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;
conn-&gt;schannel_cred.paCred&nbsp;&nbsp;&nbsp;&nbsp; = &amp;pCertContext;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; status =
global-&gt;sspi-&gt;AcquireCredentialsHandle(<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; NULL, UNISP_NAME, SECPKG_CRED_OUTBOUND, NULL,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &amp;conn-&gt;schannel_cred, NULL, NULL,
&amp;conn-&gt;creds, &amp;ts_expiry);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp; sspi_flags =
ISC_REQ_REPLAY_DETECT |<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ISC_REQ_CONFIDENTIALITY |<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ISC_RET_EXTENDED_ERROR |<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ISC_REQ_ALLOCATE_MEMORY |<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ISC_REQ_MANUAL_CRED_VALIDATION;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbufs[0].pvBuffer =
NULL;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbufs[0].BufferType
= SECBUFFER_TOKEN;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbufs[0].cbBuffer =
0;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbuf.cBuffers = 1;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbuf.pBuffers =
outbufs;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outbuf.ulVersion =
SECBUFFER_VERSION;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**** THIS CALL
GOES BOOM **********/<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in'><font size=1 face="Courier New"><span
style='font-size:9.0pt;font-family:"Courier New"'>//<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status =
global-&gt;sspi-&gt;InitializeSecurityContext(<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;conn-&gt;creds, NULL, NULL,
sspi_flags, 0,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SECURITY_NATIVE_DREP, NULL, 0,
&amp;conn-&gt;context,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;outbuf, &amp;sspi_flags_out,
&amp;ts_expiry);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>Thanks in advance,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'>Rich<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:9.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>