上两个项目中用到的Crypto内容基本中只是其中的 number theory部分,在群内自己根据密码学协议的内容自己实现了完整的过程,较少的涉及直接使用该library中的基础类。而本次不太可能自己实现所有的密码内部操作(一方面,这次是考虑AES这种过程较为繁杂的对称密码,另一方面更需要对大文件进行加密处理的IDA密码,而Crypto++里面已经较好的实现了这两种密码协议),所以需要更多的把握Crypto++的类编程接口,重新再次对Crypto++有一个深入的认识是由必要的。
基本的学习素材自然就是wiki crypto++了。
User Guide
1:Introduction
这一小Guide介绍的要求是我们必须已经对于C++相当的熟悉了,以及对于基本的密码学知识也很熟悉。这两点其实自己的能力还有待提高,但显然时间不等人,直接开始学习吧!
“therefore recommend that you learn to use Crypto++ source files as your primary reference, and only use this guide to help you in your initial orientation.”
2.Header Files
显然首先我们需要看的是一个类库的头文件,看她可以提供那些具体的服务。(当然这一点Crypto++的主页上已经有较多的介绍了)
学习一个类库显然首先需要了解它的宏观基本组织结构,最好的办法当然是看它的UML之类的类图,可以较为清晰的看清楚各个类之间的继承、交互、适配器等关系。但这里对于一个较为复杂的类库,用自然语言来概述会更加好入门一些。
“Crypto++ implements a large number of cryptographic schemes that have similar properties and behavior, but are largely independent from each other.”
主要分为七大基本的头文件类型:
2.1
Crypto++ Infrastructure
Crypto++ Infrastructure Header Files:
Header file | Description |
---|---|
cryptlib.h | Provides basic abstractions for the Crypto++ library. These include: Exception, BufferedTransformation,BlockTransformation, StreamCipher, RandomAccessStreamCipher, RandomNumberGenerator, HashTransformation,MessageAuthenticationCode, and public key crypto base classes. If Crypto++ had a most important header file, then cryptlib.h would be it. Nearly all classes defined by Crypto++ derive from base classes defined in cryptlib.h. When you need to figure out how to use one of the derived classes, your best bet is to find the relevant base class in cryptlib.h. |
filters.h | Provides additional input/output base classes (derived from BufferedTransformation): Filter and derivatives, Sink and derivatives, Source and derivatives. filters.h may be the second most important header file in Crypto++. A large number of classes in Crypto++ derive from Filter, which is an especially useful type of BufferedTransformation because of itsattachment functionality.In order to make elegant and efficient use of Crypto++, you need to be acquainted with the Filter class, as well as derived classes such as StringSource, StringSink, FileSourceand FileSink (declared in files.h). |
oids.h | Defines specific object identifiers (OIDs) that are needed by or can be used on various classes throughout the library. |
files.h | Defines classes FileStore, FileSource and FileSink (derived from Store, Source and Sink). |
network.h | Defines base classes NonblockingSource, NonblockingSink; base classes NetworkReceiver, NetworkSender; and finally, NetworkSource and NetworkSink. |
socketft.h | Encapsulates network sockets and provides Crypto++ source and sink classes for them. The following types are defined: Socket, SocketSource, SocketSink. Support for Berkeley-style as well as Windows-style sockets is provided. |
misc.h | A bunch of bit and byte manipulating functions like BytePrecision(), bitReverse(), etc. Also defines template class SecBlock, a somewhat secure memory management class used for rudimentary protection of sensitive data in Crypto++. |
smartp |