[Encryption/Decryption] compilation of the C ++ Encryption Algorithm Library Botan in Windows and Linux

Source: Internet
Author: User
Tags windows support
Compilation of C ++ Encryption Algorithm Library Botan in Windows and Linux

(1) Botan Introduction

Botan Official Website: http://botan.randombit.net/

Botan is a C ++ encryption algorithm library that supports AES, Des, SHA-1, RSA, DSA, Diffie-Hellman, and other algorithms. It supports X.509 authentication and crls and PKCS #10.

Introduction: http://www.oschina.net/p/botan

Implemented algorithm: http://botan.randombit.net/algos.html
Certificate --------------------------------------------------------------------------------------------------------------------------------------
Botan provides a number of different cryptographic algorithms and primitives, including:

Public key cryptography

Encryption algorithms RSA, ElGamal, dlies (padding schemes OAEP, PKCS #1 v1.5)
Signature algorithms RSA, DSA, ECDSA, GOST 34.10-2001, Nyberg-rueppel, Rabin-Williams (padding schemes PSS, PKCS #1 v1.5, x9.31)
Key Agreement techniques Diffie-Hellman and ecdh

Hash Functions

NIST hashes: SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512
Ripe hashes: RIPEMD-160 and RIPEMD-128
SHA-3 candidates skein-512, keccak, and blue midnight wish-512
Other common hash functions whirlpool and tiger
National Standard hashes has-160 and GOST 34.11
Obsolete or insecure hashes MD5, md4, md2
Non-Cryptographic checksums adler32, crc24, CRC32

Block Ciphers

AES (Rijndael) and AES candidates serpent, twofish, Mars, cast-256, rc6
Des, and variants 3DES and desx
National/Telecom Block Ciphers seed, Kasumi, misty1, GOST 28147, skipjack
Other Block Ciphers including blowfish, cast-128, idea, noekeon, tea, xtea, RC2, RC5, SAFER-SK, and square
Block Cipher constructions Luby-Rackoff and Lion
Block Cipher modes ECB, CBC, CBC/CTS, CFB, ofB, CTR, XTs and authenticated cipher mode eax
Stream Ciphers arc4, salsa20/xsalsa20, Turing, and widerwake4 + 1
Authentication codes HMAC, CMAC (aka omac1), CBC-MAC, ANSI X9.19 DES-MAC, and the protocol-specific SSLv3 authentication code

Public Key Infrastructure
X.509 certificates (including generating new self-Signed and Ca CERTS) and crls
Certificate Path Validation
PKCS #10 Certificate requests (creation and certificate issue)
Other cryptographic utility functions including
Key derivation functions for passwords: pbkdf1 (PKCS #5 v1.5), pbkdf2 (PKCS #5 V2.0), openpgp s2k (RFC 2440)
General key derivation functions kdf1 and kdf2 from IEEE 1363
Prfs from ANSI x9.42, SSL V3.0, TLS V1.0

Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(1) Botan Compilation

Download: click the following link on the official Botan website to go To the download page:

Getting the latest sources

Latest stable version: 1.10.1

Previous stable version: 1.8.13

Botan compilation requires Python support. A certain version of Botan can only be compiled on some versions of Python.

(1) Compile in Linux

(I) download 1.8.13 source code, http://botan.randombit.net/files/Botan-1.8.13.tgz

Decompress the package and check the configure. py file to determine which version of python can be compiled. 1.10.1 can be compiled in Python-2.5 or later versions, and 1.8.13 can be compiled in Python 2.4.

For example, the configure. py file of version 1.8.13 is written as follows:

Tested with   CPython 2.4, 2.5, 2.6 - OK   Jython 2.5 - Target detection does not work (use --os and --cpu)   CPython 2.3 and earlier are not supportedHas not been tested with IronPython or PyPy

We can see that this version is compiled on 2.4, 2.5, and 2.6, and cannot be passed in both 2.3 and earlier versions;

My operating system is centos release 5.5, and the default Python version is 2.4.

(Ii) Compilation

The procedure is as follows:
[Root @ glnode04 Botan-1.8.13] # Python Configure. py
[Root @ glnode04 Botan-1.8.13] # make install
After the command is executed, the Botan is installed in the/usr/local directory:
/Usr/local/lib directory is the library file, such as: libbotan-1.8.13.so, libbotan..
The/usr/local/include/Botan directory contains the header file.
The/usr/local/bin directory contains the executable Botan-config file.

When writing a program, use # include <Botan/xxx. h> directly. GCC will automatically search for the header file in/usr/local/include.
During compilation, add-lbotan directly. GCC will automatically go to/usr/local/lib to find the library.
Finally, add/usr/local/lib to the/etc/lD. So. conf file, and run ldconfig to find the dynamic library file of Botan.

(2) Compile in Windows

Compiling in Windows is also relatively simple. Of course, Python must be installed first.

If Visual Studio is used, we strongly recommend that you use Visual Studio's command line tool to compile the program. If you compile the program directly in the DOS command line, you need to set many environment variables. Compilation is also prone to problems.

(I) download 1.8.13 source code, http://botan.randombit.net/files/Botan-1.8.13.tgz

Decompress the package

(Ii) Compilation

Refer to official website compilation instructions

Building the library

The official website says:

On MS WindowsIf you don’t want to deal with building botan on Windows, check the website; commonly prebuilt Windows binaries with installers are available, especially for stable versions.You need to have a copy of Python installed, and have both Python and your chosen compiler in your path. Open a command shell (or the SDK shell), and run:> python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]> nmake> nmake check # optional, but recommended> nmake installFor Win95 pre OSR2, the cryptoapi_rng module will not work, because CryptoAPI didn’t exist. And all versions of NT4 lack the ToolHelp32 interface, which is how win32_stats does its slow polls, so a version of the library built with that module will not load under NT4. Later versions of Windows support both methods, so this shouldn’t be much of an issue anymore.By default the install target will be C:\botan; you can modify this with the --prefix option.When building your applications, all you have to do is tell the compiler to look for both include files and library files in C:\botan, and it will find both. Or you can move them to a place where they will be in the default compiler search paths (consult your documentation and/or local expert for details).

The following problems may occur during doscommand line compilation:

Cl.exe/MD/ibuild \ include/O2/ehs/ gr/d_console/dbotan_dll =__ declspec (dllexport)/nologo/c src \ algo_factory \ algo_factory.cpp/fobuild \ Lib \ release
Build \ include \ Botan/javastn. H (12): Fatal error c1083: Unable to open include file: "exception": no such file or directory

Correct compilation method:
Open the Visual Studio 2005 command prompt and execute the preceding command in the command line. -- cc = msvc indicates that vs compiler is used, that is, Cl

> python configure.py --cc=msvc> nmake> nmake check # optional, but recommended> nmake install

The header file and library file generated after compilation are at c: \ Botan.

(Iii) Use Botan in

Tools --> options --> projects and solutions --> VC ++ directory

Add the following content:

1) include file: C: \ Botan \ include

2) library files: C: \ Botan

Right-click the project, select Properties, select debug, linker, input, and add the dependency project to Botan. Lib.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.