Crypto++再复习【1】

本文档详细介绍了Crypto++库的主要组成部分,包括基础设施、数据操作、随机数生成、哈希函数和MAC、块密码、流密码、公钥密码系统。重点讨论了BufferedTransformation基类,它是Crypto++的核心,以及与其相关的Filter、Source和Sink抽象基类,解释了它们在数据处理中的作用和工作原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      上两个项目中用到的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: ExceptionBufferedTransformation,BlockTransformationStreamCipherRandomAccessStreamCipherRandomNumberGeneratorHashTransformation,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 StringSourceStringSinkFileSourceand 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 FileStoreFileSource and FileSink (derived from StoreSource and Sink).
network.h Defines base classes NonblockingSourceNonblockingSink; base classes NetworkReceiverNetworkSender; and finally, NetworkSource and NetworkSink.
socketft.h Encapsulates network sockets and provides Crypto++ source and sink classes for them. The following types are defined: SocketSocketSourceSocketSink. 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值