Cbc_crypt, des_setparity, or Ecb_crypt subroutine

Source: Internet
Author: User

Turn from: http://www.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/libs/commtrf1/cbc_crypt.htm

Purpose

Implements Data Encryption Standard (DES) encryption routines. Library

DES Library (libdes.a) Syntax

# include <des_crypt.h>
int Ecb_crypt (keydatadatalenmode)
char *key;
char *data;
 Datalen;
 mode;
int Cbc_crypt (keydatadatalenmodeivec)
char *key;
char *data;
Datalen;
 mode;
 Ivec;
void des_setparity (key)
char *key;
Description

The ecb_crypt and cbc_crypt subroutines implement DES encryption routines, set by the National Bureau of Standards. The Ecb_crypt subroutine encrypts in ECB (Electronic Code book) mode, which encrypts the blocks of data independently . The Cbc_crypt subroutine encrypts in CBC (Cipher block chaining) mode, which chains, together successive. CBC mode protects against insertions, deletions, and substitutions of blocks. Also, regularities in the clear text won't appear in the cipher text. Note: The DES library must is installed to use this subroutines. Parameters

Data Specifies that's the data is either encrypted or decrypted.
Datalen Specifies the length in bytes of data. The length must be a multiple of 8.
Key Specifies the 8-byte encryption key with parity. To set the "parity for" key, which for DES are in the "low" bit of each byte, use the des_setparity subroutine.
Ivec Initializes the vector for the chaining in 8-byte. This is updated to the next initialization vector upon return.
Mode Specifies whether the data is to be encrypted or decrypted. This parameter was formed by logically oring the des_encrypt or des_decrypt. For software versus hardware encryption, logically or the des_hw or des_sw. These four symbols are defined in the /usr/include/des_crypt.h file.
return Values
Deserr_badparam Specifies that a bad parameter is passed to routine.
Deserr_hwerr Specifies that a error occurred in the hardware or driver.
Deserr_nohwdevice Specifies that encryption succeeded, but was do in software instead of the requested hardware.
Deserr_none Specifies no error.
Note:Given the StatVariable, for example, which contains the return value for either the Ecb_cryptOr Cbc_cryptsubroutine, the des_failed (STAT)Macro is false to the Deserr_noneand Deserr_nohwdevicereturn values. Implementation Specifics

These subroutines are are not available for export outside the United States. Files

/usr/include/des_crypt.h Defines macros and needed symbols for the mode parameter.

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.