mirror of
https://github.com/outbackdingo/ports.git
synced 2026-01-27 18:20:07 +00:00
New port : liboauth-1.0.3
This commit is contained in:
2
main/liboauth/.checksums
Normal file
2
main/liboauth/.checksums
Normal file
@@ -0,0 +1,2 @@
|
||||
a334455fe331672cd20c131e61e86df7 liboauth-1.0.3.tar.gz
|
||||
6daacc57bb5e01934e39582fa755294c openssl.patch
|
||||
17
main/liboauth/.pkgfiles
Normal file
17
main/liboauth/.pkgfiles
Normal file
@@ -0,0 +1,17 @@
|
||||
liboauth-1.0.3-1
|
||||
drwxr-xr-x root/root usr/
|
||||
drwxr-xr-x root/root usr/include/
|
||||
-rw-r--r-- root/root usr/include/oauth.h
|
||||
drwxr-xr-x root/root usr/lib/
|
||||
lrwxrwxrwx root/root usr/lib/liboauth.so -> liboauth.so.0.8.7
|
||||
lrwxrwxrwx root/root usr/lib/liboauth.so.0 -> liboauth.so.0.8.7
|
||||
-rwxr-xr-x root/root usr/lib/liboauth.so.0.8.7
|
||||
drwxr-xr-x root/root usr/lib/pkgconfig/
|
||||
-rw-r--r-- root/root usr/lib/pkgconfig/oauth.pc
|
||||
drwxr-xr-x root/root usr/share/
|
||||
drwxr-xr-x root/root usr/share/licenses/
|
||||
drwxr-xr-x root/root usr/share/licenses/liboauth/
|
||||
-rw-r--r-- root/root usr/share/licenses/liboauth/COPYING.MIT
|
||||
drwxr-xr-x root/root usr/share/man/
|
||||
drwxr-xr-x root/root usr/share/man/man3/
|
||||
-rw-r--r-- root/root usr/share/man/man3/oauth.3.gz
|
||||
136
main/liboauth/openssl.patch
Normal file
136
main/liboauth/openssl.patch
Normal file
@@ -0,0 +1,136 @@
|
||||
--- src/hash.c.orig 2013-10-04 13:02:50 UTC
|
||||
+++ src/hash.c
|
||||
@@ -362,6 +362,11 @@ looser:
|
||||
#include "oauth.h" // base64 encode fn's.
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000
|
||||
+#define EVP_MD_CTX_new EVP_MD_CTX_create
|
||||
+#define EVP_MD_CTX_free EVP_MD_CTX_destroy
|
||||
+#endif
|
||||
+
|
||||
char *oauth_sign_hmac_sha1 (const char *m, const char *k) {
|
||||
return(oauth_sign_hmac_sha1_raw (m, strlen(m), k, strlen(k)));
|
||||
}
|
||||
@@ -386,7 +391,7 @@ char *oauth_sign_rsa_sha1 (const char *m
|
||||
unsigned char *sig = NULL;
|
||||
unsigned char *passphrase = NULL;
|
||||
unsigned int len=0;
|
||||
- EVP_MD_CTX md_ctx;
|
||||
+ EVP_MD_CTX *md_ctx;
|
||||
|
||||
EVP_PKEY *pkey;
|
||||
BIO *in;
|
||||
@@ -399,24 +404,32 @@ char *oauth_sign_rsa_sha1 (const char *m
|
||||
return xstrdup("liboauth/OpenSSL: can not read private key");
|
||||
}
|
||||
|
||||
+ md_ctx = EVP_MD_CTX_new();
|
||||
+ if (md_ctx == NULL) {
|
||||
+ return xstrdup("liboauth/OpenSSL: failed to allocate EVP_MD_CTX");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
len = EVP_PKEY_size(pkey);
|
||||
sig = (unsigned char*)xmalloc((len+1)*sizeof(char));
|
||||
|
||||
- EVP_SignInit(&md_ctx, EVP_sha1());
|
||||
- EVP_SignUpdate(&md_ctx, m, strlen(m));
|
||||
- if (EVP_SignFinal (&md_ctx, sig, &len, pkey)) {
|
||||
+ EVP_SignInit(md_ctx, EVP_sha1());
|
||||
+ EVP_SignUpdate(md_ctx, m, strlen(m));
|
||||
+ if (EVP_SignFinal (md_ctx, sig, &len, pkey)) {
|
||||
char *tmp;
|
||||
sig[len] = '\0';
|
||||
tmp = oauth_encode_base64(len,sig);
|
||||
OPENSSL_free(sig);
|
||||
EVP_PKEY_free(pkey);
|
||||
+ EVP_MD_CTX_free(md_ctx);
|
||||
return tmp;
|
||||
}
|
||||
+ EVP_MD_CTX_free(md_ctx);
|
||||
return xstrdup("liboauth/OpenSSL: rsa-sha1 signing failed");
|
||||
}
|
||||
|
||||
int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) {
|
||||
- EVP_MD_CTX md_ctx;
|
||||
+ EVP_MD_CTX *md_ctx;
|
||||
EVP_PKEY *pkey;
|
||||
BIO *in;
|
||||
X509 *cert = NULL;
|
||||
@@ -437,13 +450,18 @@ int oauth_verify_rsa_sha1 (const char *m
|
||||
return -2;
|
||||
}
|
||||
|
||||
+ md_ctx = EVP_MD_CTX_new();
|
||||
+ if (md_ctx == NULL) {
|
||||
+ return -2;
|
||||
+ }
|
||||
+
|
||||
b64d= (unsigned char*) xmalloc(sizeof(char)*strlen(s));
|
||||
slen = oauth_decode_base64(b64d, s);
|
||||
|
||||
- EVP_VerifyInit(&md_ctx, EVP_sha1());
|
||||
- EVP_VerifyUpdate(&md_ctx, m, strlen(m));
|
||||
- err = EVP_VerifyFinal(&md_ctx, b64d, slen, pkey);
|
||||
- EVP_MD_CTX_cleanup(&md_ctx);
|
||||
+ EVP_VerifyInit(md_ctx, EVP_sha1());
|
||||
+ EVP_VerifyUpdate(md_ctx, m, strlen(m));
|
||||
+ err = EVP_VerifyFinal(md_ctx, b64d, slen, pkey);
|
||||
+ EVP_MD_CTX_free(md_ctx);
|
||||
EVP_PKEY_free(pkey);
|
||||
xfree(b64d);
|
||||
return (err);
|
||||
@@ -455,35 +473,41 @@ int oauth_verify_rsa_sha1 (const char *m
|
||||
*/
|
||||
char *oauth_body_hash_file(char *filename) {
|
||||
unsigned char fb[BUFSIZ];
|
||||
- EVP_MD_CTX ctx;
|
||||
+ EVP_MD_CTX *ctx;
|
||||
size_t len=0;
|
||||
unsigned char *md;
|
||||
FILE *F= fopen(filename, "r");
|
||||
if (!F) return NULL;
|
||||
|
||||
- EVP_MD_CTX_init(&ctx);
|
||||
- EVP_DigestInit(&ctx,EVP_sha1());
|
||||
+ ctx = EVP_MD_CTX_new();
|
||||
+ if (ctx == NULL) {
|
||||
+ return xstrdup("liboauth/OpenSSL: failed to allocate EVP_MD_CTX");
|
||||
+ }
|
||||
+ EVP_DigestInit(ctx,EVP_sha1());
|
||||
while (!feof(F) && (len=fread(fb,sizeof(char),BUFSIZ, F))>0) {
|
||||
- EVP_DigestUpdate(&ctx, fb, len);
|
||||
+ EVP_DigestUpdate(ctx, fb, len);
|
||||
}
|
||||
fclose(F);
|
||||
len=0;
|
||||
md=(unsigned char*) xcalloc(EVP_MD_size(EVP_sha1()),sizeof(unsigned char));
|
||||
- EVP_DigestFinal(&ctx, md,(unsigned int*) &len);
|
||||
- EVP_MD_CTX_cleanup(&ctx);
|
||||
+ EVP_DigestFinal(ctx, md,(unsigned int*) &len);
|
||||
+ EVP_MD_CTX_free(ctx);
|
||||
return oauth_body_hash_encode(len, md);
|
||||
}
|
||||
|
||||
char *oauth_body_hash_data(size_t length, const char *data) {
|
||||
- EVP_MD_CTX ctx;
|
||||
+ EVP_MD_CTX *ctx;
|
||||
size_t len=0;
|
||||
unsigned char *md;
|
||||
md=(unsigned char*) xcalloc(EVP_MD_size(EVP_sha1()),sizeof(unsigned char));
|
||||
- EVP_MD_CTX_init(&ctx);
|
||||
- EVP_DigestInit(&ctx,EVP_sha1());
|
||||
- EVP_DigestUpdate(&ctx, data, length);
|
||||
- EVP_DigestFinal(&ctx, md,(unsigned int*) &len);
|
||||
- EVP_MD_CTX_cleanup(&ctx);
|
||||
+ ctx = EVP_MD_CTX_new();
|
||||
+ if (ctx == NULL) {
|
||||
+ return xstrdup("liboauth/OpenSSL: failed to allocate EVP_MD_CTX");
|
||||
+ }
|
||||
+ EVP_DigestInit(ctx,EVP_sha1());
|
||||
+ EVP_DigestUpdate(ctx, data, length);
|
||||
+ EVP_DigestFinal(ctx, md,(unsigned int*) &len);
|
||||
+ EVP_MD_CTX_free(ctx);
|
||||
return oauth_body_hash_encode(len, md);
|
||||
}
|
||||
23
main/liboauth/spkgbuild
Normal file
23
main/liboauth/spkgbuild
Normal file
@@ -0,0 +1,23 @@
|
||||
# description : C library implementing OAuth Core RFC 5849
|
||||
# homepage : https://github.com/x42/liboauth
|
||||
# depends : curl nss m4
|
||||
|
||||
name=liboauth
|
||||
version=1.0.3
|
||||
release=1
|
||||
source="$name-$version.tar.gz::https://github.com/x42/liboauth/archive/refs/tags/v$version.tar.gz
|
||||
openssl.patch"
|
||||
|
||||
build() {
|
||||
|
||||
cd $name-$version
|
||||
|
||||
cd src && patch -Np1 < ../../openssl.patch
|
||||
cd ..
|
||||
autoreconf -fvi
|
||||
./configure --prefix=/usr --disable-static --enable-nss
|
||||
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
|
||||
make
|
||||
make DESTDIR="$PKG" install
|
||||
install -Dt "$PKG/usr/share/licenses/$name" -m644 COPYING.MIT
|
||||
}
|
||||
Reference in New Issue
Block a user