<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>David LeBlanc's Web Log - All Comments</title><link>http://blogs.msdn.com/b/david_leblanc/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Compilers, Integers and Optimizations</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2011/12/23/compilers-integers-and-optimizations.aspx#10250846</link><pubDate>Sat, 24 Dec 2011 16:31:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10250846</guid><dc:creator>Pascal Cuoq</dc:creator><description>&lt;p&gt;&amp;gt; (int)(~(unsigned int)x + 1)&lt;/p&gt;
&lt;p&gt;&amp;gt; This does the right thing, and forces the compiler to do the right thing,&lt;/p&gt;
&lt;p&gt;&amp;gt; because now everything is defined by the standard.&lt;/p&gt;
&lt;p&gt;Almost. The cast to int is implementation-defined, not defined by the standard. Everything else in the expression is defined by the standard.&lt;/p&gt;
&lt;p&gt;[dcl] Well, yes, but that&amp;#39;s only because the representation of negative numbers is a matter of choice, and I&amp;#39;ve already established that this only works for two&amp;#39;s complement. The number of bits used for the int are also implementation-defined, but that doesn&amp;#39;t matter to the expression.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10250846" width="1" height="1"&gt;</description></item><item><title>re: Compilers, Integers and Optimizations</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2011/12/23/compilers-integers-and-optimizations.aspx#10250762</link><pubDate>Fri, 23 Dec 2011 21:24:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10250762</guid><dc:creator>Ben Craig</dc:creator><description>&lt;p&gt;Sometimes I wonder if it would be easier to just use inline assembly for some of SafeInt. &amp;nbsp;You could then leverage the &amp;quot;JC&amp;quot; (Jump if Carry) instruction, and possibly avoid a ton of compiler woes.&lt;/p&gt;
&lt;p&gt;Of course, I haven&amp;#39;t tried it myself, and I you would still need a bunch of C++ code to deal with mixed types.&lt;/p&gt;
&lt;p&gt;[dcl] We tired that, and as soon as you start inlining assembly, the compiler figures you know what you&amp;#39;re doing, and quits optimizing. Turns out the compiler is smarter than we are, and perf was horrible. You also end up non-portable.&lt;br /&gt;&lt;br /&gt;What I&amp;#39;d like is for the compilers to give me intrinsics for more of this. I was able to use intrinsics for the 64-bit multiplication, and it resulted in much smaller code. Or over the very, very long haul, it would be great if the processors had instructions for some of this, but at the moment, I see more different processors and compilers in use for most of us, so portability wins.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10250762" width="1" height="1"&gt;</description></item><item><title>re: More on Checking Allocations</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2008/04/21/more-on-checking-allocations.aspx#10183855</link><pubDate>Thu, 07 Jul 2011 00:00:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10183855</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;p&gt;Don&amp;#39;t forget this:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://support.microsoft.com/kb/284893"&gt;support.microsoft.com/.../284893&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10183855" width="1" height="1"&gt;</description></item><item><title>re: MS-Offcrypto Examples</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2009/01/06/ms-offcrypto-examples.aspx#10166301</link><pubDate>Thu, 19 May 2011 14:32:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10166301</guid><dc:creator>Daniel</dc:creator><description>&lt;p&gt;For Standard Encryption, this is great but would you consider creating a sample project to illustrate Agile Encryption?&lt;/p&gt;
&lt;p&gt;[dcl] - Yes, I should do that&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10166301" width="1" height="1"&gt;</description></item><item><title>re: Don’t Forget the Document Password!</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2007/04/01/don-t-forget-the-document-password.aspx#10144240</link><pubDate>Tue, 22 Mar 2011 10:04:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10144240</guid><dc:creator>AlexKr</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Unfortunately AES security does not really help if you consider distributed approach.&lt;/p&gt;
&lt;p&gt;For example, &lt;a href="http://passwordnow.com" rel="nofollow" target="_new"&gt;http://passwordnow.com&lt;/a&gt; offers their cluster to recover even office 2007-2010 documents.&lt;/p&gt;
&lt;p&gt;It works in the following way.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say the average PC gets 100 passwords per second. Then you get 1000 cores working together, thats 100K passwords per second.&lt;/p&gt;
&lt;p&gt;Assuming most of the users are NOT using strong passwords the brute force search will eventually uncover most of the data.&lt;/p&gt;
&lt;p&gt;So it is really a job for a user to use the correct passwords.&lt;/p&gt;
&lt;p&gt;I would even say it is mandatory to have such education about choosing correct passwords.&lt;/p&gt;
&lt;p&gt;Best wishes,&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
&lt;p&gt;[dcl] Sure it helps - let&amp;#39;s look at the math. An iterated hash can drop your cracks/second by anywhere from 5-6 orders of magnitude. A cluster of 1000 systems only gains you 3 orders of magnitude. The password is still effectively 100x stronger using a well-build KDF than not. This will obviously not save you if the password is poorly chosen, but it takes a 3-day password crack out to 300 days. Most people give up long before that, and aren&amp;#39;t willing to throw 3 million computer-days at the problem.&lt;/p&gt;
&lt;p&gt;And to be clear, it isn&amp;#39;t AES that saves you - AES does nearly nothing here. It&amp;#39;s the key derivation function that&amp;#39;s important.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10144240" width="1" height="1"&gt;</description></item><item><title>re: Office 2007 SP2 Encryption Settings</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2009/05/20/office-2007-sp2-encryption-settings.aspx#10112060</link><pubDate>Wed, 05 Jan 2011 15:50:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10112060</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Does Office 2007 encryption protect embedded objects? &amp;nbsp;This PC World article (&lt;a href="http://www.pcworld.com/article/5606/encryption_does_not_protect_oleembedded_files.html" rel="nofollow" target="_new"&gt;www.pcworld.com/.../encryption_does_not_protect_oleembedded_files.html&lt;/a&gt;) indicated that back in 1997 Office&amp;#39;s encryption did NOT protect embedded files. &amp;nbsp;Has this been changed?&lt;/p&gt;
&lt;p&gt;Put differently: If I embed a PDF or an Excel worksheet in a Word 2007 .docx and then encrypt the .docx, is the embedded file also protected?&lt;/p&gt;
&lt;p&gt;[dcl] Yes - if you&amp;#39;re encrypting a docx, or any other OOXML file, embedded objects are protected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10112060" width="1" height="1"&gt;</description></item><item><title>re: Office Crypto Follies</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2008/07/03/office-crypto-follies.aspx#10078748</link><pubDate>Thu, 21 Oct 2010 04:35:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10078748</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;p&gt;&amp;quot;Sadly, most of the implementation flaws remained. I found one place where there was triple key stream re-use (though only for 8 bytes) in the same spot.&amp;quot;&lt;/p&gt;
&lt;p&gt;Worse. If you read MS-DOC or MS-XLS, each stream is encrypted with a block number starting at zero *for each stream*. If you read MS-OFFCRYPTO, you will read there is no place where the name of the stream is mixed into the key. This means *each stream* is encrypted with the *same* set of keys.&lt;/p&gt;
&lt;p&gt;[dcl] yes, this is why I say to just not use the RC4 encryption. Upgrade the file to a new format, and get good encryption. Or use something else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10078748" width="1" height="1"&gt;</description></item><item><title>re: Don’t Use Office RC4 Encryption. Really. Just don’t do it.</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2010/04/16/don-t-use-office-rc4-encryption-really-just-don-t-do-it.aspx#10070172</link><pubDate>Fri, 01 Oct 2010 05:49:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10070172</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;p&gt;Could Office be updated to use different RC4 keystreams on each save without breaking the file format?&lt;/p&gt;
&lt;p&gt;I think it is likely.&lt;/p&gt;
&lt;p&gt;[dcl] No - we looked at that, and the problem, as always, is backward compatibility. If all you use is the CAPI 128-bit RC4, then things get better, but are still not great.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10070172" width="1" height="1"&gt;</description></item><item><title>re: Another technique for Fixing DLL Preloading attacks</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2010/08/23/another-technique-for-fixing-dll-preloading-attacks.aspx#10054103</link><pubDate>Wed, 25 Aug 2010 14:18:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10054103</guid><dc:creator>janglin</dc:creator><description>&lt;p&gt;Is this how you would use SetDllDirectory? &lt;/p&gt;
&lt;p&gt;typedef BOOL (WINAPI *PSDLLD)(__in_opt LPCWSTR);&lt;/p&gt;
&lt;p&gt;HMODULE SafeLoadLibrary_1(const wchar_t* wzFileName)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;HMODULE hMod = NULL;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;static PSDLLD pSetDllDirectory = NULL;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;if (NULL == pSetDllDirectory)&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pSetDllDirectory = (PSDLLD)GetProcAddress(GetModuleHandleW(L&amp;quot;kernel32.dll&amp;quot;), &lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;SetDllDirectoryW&amp;quot;);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;if (NULL != pSetDllDirectory)&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (pSetDllDirectory(L&amp;quot;&amp;quot;)) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// remove &amp;#39;.&amp;#39; from search order&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hMod = LoadLibrary(wzFileName);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pSetDllDirectory(NULL); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // restore default search order&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;return hMod;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;[dcl] Well, you could. Unless you&amp;#39;re supporting Windows 2000 or XP gold, you can skip getting the proc address of SetDllDirectory. The problem with this is that it is process-wide and not thread safe. What I&amp;#39;d really recommend instead is just call SetDllDirectory(&amp;quot;&amp;quot;) as the first thing you do in main() or WinMain(), and just run like that.&lt;/p&gt;
&lt;p&gt;If you have problems with doing that, and sometimes need the option of using the CWD, then you can&amp;#39;t do that, and need to take some other approach, like the example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10054103" width="1" height="1"&gt;</description></item><item><title>re: Another technique for Fixing DLL Preloading attacks</title><link>http://blogs.msdn.com/b/david_leblanc/archive/2010/08/23/another-technique-for-fixing-dll-preloading-attacks.aspx#10053546</link><pubDate>Tue, 24 Aug 2010 12:28:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10053546</guid><dc:creator>asf</dc:creator><description>&lt;p&gt;static wchar_t wzSystem[MAX_PATH]={0}; ?&lt;/p&gt;
&lt;p&gt;[dcl] The language standard says that all globals and statics get initialized, and failing a constructor, they get initialized to zero.&lt;/p&gt;
&lt;p&gt;Also, MAX_PATH limit is evil&lt;/p&gt;
&lt;p&gt;[dcl] Not really. Try installing Windows into a directory that won&amp;#39;t fit in MAX_PATH, and my prediction is that it won&amp;#39;t go well. You could potentially have issues with the CWD, and if you&amp;#39;re worried about it, write the code to fall back and allocate the buffer. While this is fairly close to production quality, it is sample code, and could use more error checking and one might want to make it more robust.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10053546" width="1" height="1"&gt;</description></item></channel></rss>