Fossil SCM
If Openssl is available, use its ssh1 implementation. Suggested by Baruch Burstein.
Commit
379309b6da2b73fddf4bb82204b935375a6d883f
Parent
d00f2cfa8069bc2…
1 file changed
+10
+10
| --- src/sha1.c | ||
| +++ src/sha1.c | ||
| @@ -3,10 +3,19 @@ | ||
| 3 | 3 | */ |
| 4 | 4 | #include "config.h" |
| 5 | 5 | #include <sys/types.h> |
| 6 | 6 | #include "sha1.h" |
| 7 | 7 | |
| 8 | +#ifdef FOSSIL_ENABLE_SSL | |
| 9 | + | |
| 10 | +# include <openssl/sha.h> | |
| 11 | +# define SHA1Context SHA_CTX | |
| 12 | +# define SHA1Init SHA1_Init | |
| 13 | +# define SHA1Update SHA1_Update | |
| 14 | +# define SHA1Final(a,b) SHA1_Final(b,a) | |
| 15 | + | |
| 16 | +#else | |
| 8 | 17 | |
| 9 | 18 | /* |
| 10 | 19 | ** The SHA1 implementation below is adapted from: |
| 11 | 20 | ** |
| 12 | 21 | ** $NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $ |
| @@ -198,10 +207,11 @@ | ||
| 198 | 207 | for (i = 0; i < 20; i++) |
| 199 | 208 | digest[i] = (unsigned char) |
| 200 | 209 | ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); |
| 201 | 210 | } |
| 202 | 211 | } |
| 212 | +#endif | |
| 203 | 213 | |
| 204 | 214 | |
| 205 | 215 | /* |
| 206 | 216 | ** Convert a digest into base-16. digest should be declared as |
| 207 | 217 | ** "unsigned char digest[20]" in the calling function. The SHA1 |
| 208 | 218 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -3,10 +3,19 @@ | |
| 3 | */ |
| 4 | #include "config.h" |
| 5 | #include <sys/types.h> |
| 6 | #include "sha1.h" |
| 7 | |
| 8 | |
| 9 | /* |
| 10 | ** The SHA1 implementation below is adapted from: |
| 11 | ** |
| 12 | ** $NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $ |
| @@ -198,10 +207,11 @@ | |
| 198 | for (i = 0; i < 20; i++) |
| 199 | digest[i] = (unsigned char) |
| 200 | ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | |
| 205 | /* |
| 206 | ** Convert a digest into base-16. digest should be declared as |
| 207 | ** "unsigned char digest[20]" in the calling function. The SHA1 |
| 208 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -3,10 +3,19 @@ | |
| 3 | */ |
| 4 | #include "config.h" |
| 5 | #include <sys/types.h> |
| 6 | #include "sha1.h" |
| 7 | |
| 8 | #ifdef FOSSIL_ENABLE_SSL |
| 9 | |
| 10 | # include <openssl/sha.h> |
| 11 | # define SHA1Context SHA_CTX |
| 12 | # define SHA1Init SHA1_Init |
| 13 | # define SHA1Update SHA1_Update |
| 14 | # define SHA1Final(a,b) SHA1_Final(b,a) |
| 15 | |
| 16 | #else |
| 17 | |
| 18 | /* |
| 19 | ** The SHA1 implementation below is adapted from: |
| 20 | ** |
| 21 | ** $NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $ |
| @@ -198,10 +207,11 @@ | |
| 207 | for (i = 0; i < 20; i++) |
| 208 | digest[i] = (unsigned char) |
| 209 | ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); |
| 210 | } |
| 211 | } |
| 212 | #endif |
| 213 | |
| 214 | |
| 215 | /* |
| 216 | ** Convert a digest into base-16. digest should be declared as |
| 217 | ** "unsigned char digest[20]" in the calling function. The SHA1 |
| 218 |