摘要: block cipher已经有很多了,3DES、blowfish、AES...加密算法给出的是:给定key和plaintext,如何变换得到ciphertext。从加密算法开始,如何得到一个加密文件的可用程序,还有一段路要走,主要面对的问题是:1,从文件到plaintext,文件的大小通常不是一个block大小,那么,如何分块,不同块之间如何处理,如果不能分成完整的块怎么办?2,从口令(password或者passphrase)到key,用户的加密解密口令通常是一个字符串,如“fotally”,怎么从口令得到一个key?RSA Labs的标准PKCS#5,给出了一些推荐做法,见http://w 阅读全文
posted @ 2011-05-06 16:15 qsort 阅读(302) 评论(0) 推荐(0)
摘要: 问题场景:我们有一块设备卡,上面跑着一个FreeBSD。host这边是Linux,与device那边的交互由host这边的Linux driver负责,driver在Linux下提供了几个char device来使得用户可以与device交互。这些char devices里面,有一个连接到device那边FreeBSD的终端,host端通过minicom(一个2222old的Unix程序)来通过这个char dev与device端交互,这样方便device一端的开发调试。问题:这个char device只能由一个进程来使用。那么,如果两个开发人员在同时进行开发,那么就只能在用的时候打开,用完就 阅读全文
posted @ 2011-05-06 12:53 qsort 阅读(284) 评论(0) 推荐(0)
摘要: The purpose of the algorithm is, given a curve composed of line segments, to find a similar curve with fewer points. The algorithm defines 'dissimilar' based on the maximum distance between the original curve and the simplified curve. The simplified curve consists of a subset of the points t 阅读全文
posted @ 2011-05-05 22:55 qsort 阅读(1545) 评论(0) 推荐(0)
摘要: compile time assert:#define UNIQUE(x) __unique_name##x#define STATIC_ASSERT(expr) typedef char UNIQUE(__LINE__)[(expr)?1:-1]; 阅读全文
posted @ 2011-05-05 18:14 qsort 阅读(542) 评论(0) 推荐(0)
摘要: False sharing is an inherent artifact of cache coherence protocols (like MESI and MOESI). It happens when two participants (threads) operates on different part of the same cache-line. Seehttp://en.wikipedia.org/wiki/False_sharingfor more details (and sample code). 阅读全文
posted @ 2011-05-05 18:13 qsort 阅读(168) 评论(0) 推荐(0)
摘要: #pragma GCC poisonRemove the specified identifier(s) from the program (and forbid them from appearing).Seehttp://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Pragmas.htmlfor more information. 阅读全文
posted @ 2011-05-05 18:11 qsort 阅读(748) 评论(0) 推荐(1)
摘要: __func__, __FUNCTION__, __PRETTY_FUNCTION__In C++, __PRETTY_FUNCTION__ contains the type signature of the function.Seehttp://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/Function-Names.htmlfor more information. 阅读全文
posted @ 2011-05-05 18:08 qsort 阅读(196) 评论(0) 推荐(0)
摘要: Quoting APUE2:The mutex passed to pthread_cond_wait protects the condition. The caller passes it locked to the function, which then atomically places the calling thread on the list of threads waiting for the condition and unlocks the mutex. This closes the window between the time that the condition 阅读全文
posted @ 2011-05-05 18:05 qsort 阅读(241) 评论(0) 推荐(0)
摘要: 场景:不小心删除了某文件,但该文件之前被某进程(譬如一个daemon)打开尚未关闭。注:文件删除是在打开的fd都关闭以后发生的,即,unlink一个文件以后,如果inode的引用计数降到0,这个文件应该被删除,但如果还有进程打开了这个文件且尚未关闭(即打开计数不为0),那么文件将在最后一个打开该文件的进程关闭该文件的fd以后删除。这也是为什么会有install这种命令的缘故。install会首先unlink文件,之后以同样文件名open(其实是create)该文件并写入;与之对应的是,cp命令打开文件直接写入。在install最常用的场合,安装新版本的共享库.so文件,由于要更新的.so文件可 阅读全文
posted @ 2011-05-05 18:02 qsort 阅读(237) 评论(0) 推荐(0)
摘要: Encrypted Salt-Sector Initialization Vector,自Linux Kernel 2.6.10引入的接口,用于产生安全的iv,公式如下:IV(sector) = Es(sector), where s = hash(key)参见wiki的页面http://en.wikipedia.org/wiki/Disk_encryption_theory#ESSIV 阅读全文
posted @ 2011-05-04 16:46 qsort 阅读(448) 评论(0) 推荐(0)
摘要: AES加密算法, 不说了。block cipher的各种工作模式,ECB、CBC、Counter等,不说了。Block Cipher在用作disk encryption的时候,也有许多问题要考虑。主要是ECB模式不行(很明显),CBC模式也不好(无法随机访问),所以IEEE标准化了一个P1619标准,IEEE Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices,见http://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=449 阅读全文
posted @ 2011-05-04 16:44 qsort 阅读(4663) 评论(0) 推荐(0)
摘要: 这里将用作个人知识库。 阅读全文
posted @ 2011-05-04 16:42 qsort 阅读(166) 评论(0) 推荐(0)