X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcacc%2Fsilcacc.h;h=040f1c692a8999ffde8e73679d9c92fc32ea1863;hb=80dc2a39c614ea1376a2e19ebe2460af11c9afee;hp=e438bc8c68741432dc5f501ac6d8d635fe8a4130;hpb=1218ffebfc22091283bbd73886c8e7cd734e856f;p=crypto.git diff --git a/lib/silcacc/silcacc.h b/lib/silcacc/silcacc.h index e438bc8c..040f1c69 100644 --- a/lib/silcacc/silcacc.h +++ b/lib/silcacc/silcacc.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 2008 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,16 +17,28 @@ */ -/****h* silcskr/SILC Accelerator Interface +/****h* silcacc/Crypto Accelerator Interface * * DESCRIPTION * + * SILC Crypto Accelerator Interface provides a generic interface for + * cryptographic accelerators. The interface can access different kind of + * accelerators, such as hardware accelerators. Using an accelerator can + * significantly improve encryption, decryption, signature and verification + * performance. + * + * Third-party accelerators can be registered into the accelerator interface + * and used through the same generic interface. + * + * The interface can be used to accelerate public and private keys, and + * ciphers. + * ***/ #ifndef SILCACC_H #define SILCACC_H -/****s* silcacc/SilcAccAPI/SilcAccelerator +/****s* silcacc/SilcAccelerator * * NAME * @@ -47,16 +59,16 @@ typedef struct SilcAcceleratorObject { va_list va); /* Initialize accelerator */ SilcBool (*uninit)(void); /* Uninitialize accelerator */ const SilcPKCSAlgorithm *pkcs; /* Accelerated PKCS algorithms */ + const SilcCipherObject *cipher; /* Accelerated ciphers */ #if 0 const SilcDHObject *dh; /* Accelerated Diffie-Hellmans */ - const SilcCipherObject *cipher; /* Accelerated ciphers */ const SilcHashObject *hash; /* Accelerated hashes */ const SilcHmacObject *hmac; /* Accelerated HMACs */ const SilcRngObject *rng; /* Accelerated RNG's */ #endif /* 0 */ } *SilcAccelerator, SilcAcceleratorStruct; -/****f* silcacc/SilcAccAPI/silc_acc_register +/****f* silcacc/silc_acc_register * * SYNOPSIS * @@ -76,7 +88,7 @@ typedef struct SilcAcceleratorObject { ***/ SilcBool silc_acc_register(const SilcAccelerator acc); -/****f* silcacc/SilcAccAPI/silc_acc_unregister +/****f* silcacc/silc_acc_unregister * * SYNOPSIS * @@ -90,7 +102,21 @@ SilcBool silc_acc_register(const SilcAccelerator acc); ***/ void silc_acc_unregister(SilcAccelerator acc); -/****f* silcacc/SilcAccAPI/silc_acc_init +/****f* silcacc/silc_acc_find + * + * SYNOPSIS + * + * SilcAccelerator silc_acc_find(const char *name); + * + * DESCRIPTION + * + * Find accelerator by its name indicated by `name'. Returns the + * accelerator context or NULL if such accelerator is not registered. + * + ***/ +SilcAccelerator silc_acc_find(const char *name); + +/****f* silcacc/silc_acc_init * * SYNOPSIS * @@ -112,7 +138,7 @@ void silc_acc_unregister(SilcAccelerator acc); ***/ SilcBool silc_acc_init(SilcAccelerator acc, SilcSchedule schedule, ...); -/****f* silcacc/SilcAccAPI/silc_acc_uninit +/****f* silcacc/silc_acc_uninit * * SYNOPSIS * @@ -128,7 +154,7 @@ SilcBool silc_acc_init(SilcAccelerator acc, SilcSchedule schedule, ...); ***/ SilcBool silc_acc_uninit(SilcAccelerator acc); -/****f* silcacc/SilcAccAPI/silc_acc_get_supported +/****f* silcacc/silc_acc_get_supported * * SYNOPSIS * @@ -142,21 +168,7 @@ SilcBool silc_acc_uninit(SilcAccelerator acc); ***/ SilcDList silc_acc_get_supported(void); -/****f* silcacc/SilcAccAPI/silc_acc_find - * - * SYNOPSIS - * - * SilcAccelerator silc_acc_find(const char *name); - * - * DESCRIPTION - * - * Find accelerator by its name indicated by `name'. Returns the - * accelerator context or NULL if such accelerator is not registered. - * - ***/ -SilcAccelerator silc_acc_find(const char *name); - -/****f* silcacc/SilcAccAPI/silc_acc_get_name +/****f* silcacc/silc_acc_get_name * * SYNOPSIS * @@ -169,7 +181,7 @@ SilcAccelerator silc_acc_find(const char *name); ***/ const char *silc_acc_get_name(SilcAccelerator acc); -/****f* silcacc/SilcAccAPI/silc_acc_public_key +/****f* silcacc/silc_acc_public_key * * SYNOPSIS * @@ -188,11 +200,15 @@ const char *silc_acc_get_name(SilcAccelerator acc); * The associated `public_key' can be retrieved from the returned * public key by calling silc_acc_get_public_key. * + * If this returns NULL the public key could not be accelerated. This + * usually should not be considered serious error. Instead, the public + * key should be used without acceleration. + * ***/ SilcPublicKey silc_acc_public_key(SilcAccelerator acc, SilcPublicKey public_key); -/****f* silcacc/SilcAccAPI/silc_acc_private_key +/****f* silcacc/silc_acc_private_key * * SYNOPSIS * @@ -211,11 +227,15 @@ SilcPublicKey silc_acc_public_key(SilcAccelerator acc, * The associated `private_key' can be retrieved from the returned * private key by calling silc_acc_get_private_key. * + * If this returns NULL the private key could not be accelerated. This + * usually should not be considered serious error. Instead, the private + * key should be used without acceleration. + * ***/ SilcPrivateKey silc_acc_private_key(SilcAccelerator acc, SilcPrivateKey private_key); -/****f* silcacc/SilcAccAPI/silc_acc_get_public_key +/****f* silcacc/silc_acc_get_public_key * * SYNOPSIS * @@ -232,7 +252,7 @@ SilcPrivateKey silc_acc_private_key(SilcAccelerator acc, SilcPublicKey silc_acc_get_public_key(SilcAccelerator acc, SilcPublicKey public_key); -/****f* silcacc/SilcAccAPI/silc_acc_get_private_key +/****f* silcacc/silc_acc_get_private_key * * SYNOPSIS * @@ -249,4 +269,45 @@ SilcPublicKey silc_acc_get_public_key(SilcAccelerator acc, SilcPrivateKey silc_acc_get_private_key(SilcAccelerator acc, SilcPrivateKey private_key); +/****f* silcacc/silc_acc_cipher + * + * SYNOPSIS + * + * SilcCipher silc_acc_cipher(SilcAccelerator acc, SilcCipher cipher); + * + * DESCRIPTION + * + * Accelerate the cipher indicated by `cipher'. Returns new accelerated + * SilcCipher context. It can be used just as normal cipher and must be + * freed by calilng silc_cipher_free. The associated `cipher' is not + * freed when the accelerated cipher is freed. The `cipher' must not be + * freed as long as it is accelerated. + * + * When key and IV is set for the accelerated cipher, it is also set to + * the associated cipher. + * + * The associated `cipher' can be retrieved from the accelerated cipher + * by calling silc_acc_get_cipher. + * + * If this returns NULL the cipher could not be accelerated. This + * usually should not be considered serious error. Instead, the cipher + * should be used without acceleration. + * + ***/ +SilcCipher silc_acc_cipher(SilcAccelerator acc, SilcCipher cipher); + +/****f* silcacc/silc_acc_get_cipher + * + * SYNOPSIS + * + * SilcCipher silc_acc_get_cipher(SilcAccelerator acc, SilcCipher cipher); + * + * DESCRIPTION + * + * Returns the underlaying cipher from the accelerated cipher indicated + * by `cipher'. Returns NULL if `cipher' is not accelerated cipher. + * + ***/ +SilcCipher silc_acc_get_cipher(SilcAccelerator acc, SilcCipher cipher); + #endif /* SILCACC_H */