diff options
| -rw-r--r-- | Documentation/crypto/api-intro.txt | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/Documentation/crypto/api-intro.txt b/Documentation/crypto/api-intro.txt index 74dffc68ff9f..5a03a2801d67 100644 --- a/Documentation/crypto/api-intro.txt +++ b/Documentation/crypto/api-intro.txt | |||
| @@ -19,15 +19,14 @@ At the lowest level are algorithms, which register dynamically with the | |||
| 19 | API. | 19 | API. |
| 20 | 20 | ||
| 21 | 'Transforms' are user-instantiated objects, which maintain state, handle all | 21 | 'Transforms' are user-instantiated objects, which maintain state, handle all |
| 22 | of the implementation logic (e.g. manipulating page vectors), provide an | 22 | of the implementation logic (e.g. manipulating page vectors) and provide an |
| 23 | abstraction to the underlying algorithms, and handle common logical | 23 | abstraction to the underlying algorithms. However, at the user |
| 24 | operations (e.g. cipher modes, HMAC for digests). However, at the user | ||
| 25 | level they are very simple. | 24 | level they are very simple. |
| 26 | 25 | ||
| 27 | Conceptually, the API layering looks like this: | 26 | Conceptually, the API layering looks like this: |
| 28 | 27 | ||
| 29 | [transform api] (user interface) | 28 | [transform api] (user interface) |
| 30 | [transform ops] (per-type logic glue e.g. cipher.c, digest.c) | 29 | [transform ops] (per-type logic glue e.g. cipher.c, compress.c) |
| 31 | [algorithm api] (for registering algorithms) | 30 | [algorithm api] (for registering algorithms) |
| 32 | 31 | ||
| 33 | The idea is to make the user interface and algorithm registration API | 32 | The idea is to make the user interface and algorithm registration API |
| @@ -44,22 +43,27 @@ under development. | |||
| 44 | Here's an example of how to use the API: | 43 | Here's an example of how to use the API: |
| 45 | 44 | ||
| 46 | #include <linux/crypto.h> | 45 | #include <linux/crypto.h> |
| 46 | #include <linux/err.h> | ||
| 47 | #include <linux/scatterlist.h> | ||
| 47 | 48 | ||
| 48 | struct scatterlist sg[2]; | 49 | struct scatterlist sg[2]; |
| 49 | char result[128]; | 50 | char result[128]; |
| 50 | struct crypto_tfm *tfm; | 51 | struct crypto_hash *tfm; |
| 52 | struct hash_desc desc; | ||
| 51 | 53 | ||
| 52 | tfm = crypto_alloc_tfm("md5", 0); | 54 | tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); |
| 53 | if (tfm == NULL) | 55 | if (IS_ERR(tfm)) |
| 54 | fail(); | 56 | fail(); |
| 55 | 57 | ||
| 56 | /* ... set up the scatterlists ... */ | 58 | /* ... set up the scatterlists ... */ |
| 59 | |||
| 60 | desc.tfm = tfm; | ||
| 61 | desc.flags = 0; | ||
| 57 | 62 | ||
| 58 | crypto_digest_init(tfm); | 63 | if (crypto_hash_digest(&desc, &sg, 2, result)) |
| 59 | crypto_digest_update(tfm, &sg, 2); | 64 | fail(); |
| 60 | crypto_digest_final(tfm, result); | ||
| 61 | 65 | ||
| 62 | crypto_free_tfm(tfm); | 66 | crypto_free_hash(tfm); |
| 63 | 67 | ||
| 64 | 68 | ||
| 65 | Many real examples are available in the regression test module (tcrypt.c). | 69 | Many real examples are available in the regression test module (tcrypt.c). |
| @@ -126,7 +130,7 @@ might already be working on. | |||
| 126 | BUGS | 130 | BUGS |
| 127 | 131 | ||
| 128 | Send bug reports to: | 132 | Send bug reports to: |
| 129 | James Morris <jmorris@redhat.com> | 133 | Herbert Xu <herbert@gondor.apana.org.au> |
| 130 | Cc: David S. Miller <davem@redhat.com> | 134 | Cc: David S. Miller <davem@redhat.com> |
| 131 | 135 | ||
| 132 | 136 | ||
| @@ -134,13 +138,14 @@ FURTHER INFORMATION | |||
| 134 | 138 | ||
| 135 | For further patches and various updates, including the current TODO | 139 | For further patches and various updates, including the current TODO |
| 136 | list, see: | 140 | list, see: |
| 137 | http://samba.org/~jamesm/crypto/ | 141 | http://gondor.apana.org.au/~herbert/crypto/ |
| 138 | 142 | ||
| 139 | 143 | ||
| 140 | AUTHORS | 144 | AUTHORS |
| 141 | 145 | ||
| 142 | James Morris | 146 | James Morris |
| 143 | David S. Miller | 147 | David S. Miller |
| 148 | Herbert Xu | ||
| 144 | 149 | ||
| 145 | 150 | ||
| 146 | CREDITS | 151 | CREDITS |
| @@ -238,8 +243,11 @@ Anubis algorithm contributors: | |||
| 238 | Tiger algorithm contributors: | 243 | Tiger algorithm contributors: |
| 239 | Aaron Grothe | 244 | Aaron Grothe |
| 240 | 245 | ||
| 246 | VIA PadLock contributors: | ||
| 247 | Michal Ludvig | ||
| 248 | |||
| 241 | Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com> | 249 | Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com> |
| 242 | 250 | ||
| 243 | Please send any credits updates or corrections to: | 251 | Please send any credits updates or corrections to: |
| 244 | James Morris <jmorris@redhat.com> | 252 | Herbert Xu <herbert@gondor.apana.org.au> |
| 245 | 253 | ||
