File fix-build.diff of Package perl-Crypt-GCrypt

--- ./GCrypt.xs.orig	2022-06-23 11:07:16.222695353 +0000
+++ ./GCrypt.xs	2022-06-23 11:07:28.926669825 +0000
@@ -56,9 +56,13 @@ struct Crypt_GCrypt_s {
     int type;
     int action;
     gcry_cipher_hd_t h;
+/*
     gcry_ac_handle_t h_ac;
+*/
     gcry_md_hd_t h_md;
+/*
     gcry_ac_key_t key_ac;
+*/
     gcry_error_t err;
     int mode;
     int padding;
@@ -90,7 +94,7 @@ int find_padding (Crypt_GCrypt gcr, unsi
             p = memchr((char *) string, '\0', string_len);
             if (p == NULL) return -1;
             
-            offset = (int) p - (int) string;
+            offset = p - (void *)string;
             for (i = offset; i < string_len; ++i) {
                 if (string[string_len-i] != '\0') return -1;
             }
@@ -100,7 +104,7 @@ int find_padding (Crypt_GCrypt gcr, unsi
             p = memchr((char *) string, '\32', string_len);
             if (p == NULL) return -1;
             
-            offset = (int) p - (int) string;
+            offset = p - (void *)string;
             for (i = offset; i < string_len; ++i) {
                 if (string[string_len-i] != '\32') return -1;
             }
@@ -200,10 +204,12 @@ Crypt_GCrypt
 cg_new(...)
     PROTOTYPE: @
     INIT:
-        char *s, *algo_s, *mode_s, *key_s;
+        char *s, *algo_s = NULL, *mode_s, *key_s;
         int i, algo, mode;
         unsigned int c_flags, ac_flags, md_flags;
+/*
         gcry_ac_id_t ac_algo;
+*/
         bool have_mode;
     CODE:
         New(0, RETVAL, 1, struct Crypt_GCrypt_s);
@@ -322,25 +328,19 @@ cg_new(...)
             if (!(algo = gcry_md_map_name(algo_s)))
                 croak("Unknown digest algorithm %s", algo_s);
 
-        RETVAL->err = gcry_md_open(&RETVAL->h_md, algo, md_flags);
+            RETVAL->err = gcry_md_open(&RETVAL->h_md, algo, md_flags);
             if (RETVAL->h_md == NULL) XSRETURN_UNDEF;
 
-        if (md_flags & GCRY_MD_FLAG_HMAC) {
-            /* what if this overwrites the earlier error value? */
-            RETVAL->err = gcry_md_setkey(RETVAL->h_md, key_s, RETVAL->keylen);
+            if (md_flags & GCRY_MD_FLAG_HMAC) {
+                /* what if this overwrites the earlier error value? */
+                RETVAL->err = gcry_md_setkey(RETVAL->h_md, key_s, RETVAL->keylen);
+            }
         }
-    }
         if (RETVAL->type == CG_TYPE_ASYMM) {
         
             croak("Asymmetric cryptography is not yet supported by Crypt::GCrypt");
+	    XSRETURN_UNDEF;
             
-            RETVAL->err = gcry_ac_name_to_id(algo_s, &ac_algo);
-            if (RETVAL->err)
-                croak("Unknown algorithm %s", algo_s);
-            
-            /* Init ac */
-            RETVAL->err = gcry_ac_open(&RETVAL->h_ac, ac_algo, ac_flags);
-            if (RETVAL->h_ac == NULL) XSRETURN_UNDEF;
         }
         
 
@@ -532,39 +532,6 @@ cg_decrypt(gcr, in)
     OUTPUT:
         RETVAL
 
-SV *
-cg_sign(gcr, in)
-    Crypt_GCrypt gcr;
-    SV *in;
-    PREINIT:
-        gcry_mpi_t in_mpi, out_mpi;
-        gcry_ac_data_t outdata;
-        size_t len;
-        const void *inbuf;
-        const char *label;
-        char* outbuf;
-    CODE:
-        /*
-        in_mpi = gcry_mpi_new(0);
-        out_mpi = gcry_mpi_new(0);
-        inbuf = SvPV(in, len);
-        printf("inbuf: %s\n", inbuf);
-        gcry_mpi_scan( &in_mpi, GCRYMPI_FMT_STD, inbuf, strlen(inbuf), NULL );
-        printf("Key: %s\n", gcr->key_ac);
-        gcr->err = gcry_ac_data_sign(gcr->h_ac, gcr->key_ac, in_mpi, &outdata);
-        if (gcr->err) {
-            croak( gcry_strerror(gcr->err) );
-        }
-        printf("Here\n");
-        gcr->err = gcry_ac_data_get_index (outdata, 0, 0, &label, &out_mpi);
-        printf("Before (%s)\n", label);
-        gcry_mpi_print(GCRYMPI_FMT_STD, outbuf, 1024, NULL, out_mpi);
-        printf("After\n");
-        RETVAL = newSVpv(outbuf, 0);
-        */
-    OUTPUT:
-        RETVAL
-
 void
 cg_start(gcr, act)
     Crypt_GCrypt gcr;
@@ -594,8 +561,10 @@ cg_setkey(gcr, ...)
     PREINIT:
         char *k, *s;
         char *mykey, *buf;
+/*
         gcry_ac_key_type_t keytype;
         gcry_ac_data_t keydata;
+*/
         gcry_mpi_t mpi;
         size_t len;
     CODE:
@@ -617,22 +586,7 @@ cg_setkey(gcr, ...)
         
         /* Set key for asymmetric criptography */
         if (gcr->type == CG_TYPE_ASYMM) {
-            k = SvPV(ST(2), len);
-            
-            /* Key type */
-            keytype = -1;
-            s = SvPV(ST(1), len);
-            if (strcmp(s, "private") == 0) keytype = GCRY_AC_KEY_SECRET;
-            if (strcmp(s, "public") == 0) keytype = GCRY_AC_KEY_PUBLIC;
-            if (keytype == -1)
-                croak("Key must be private or public");
-            
-            gcry_control(GCRYCTL_INIT_SECMEM, strlen(k));
-            mpi = gcry_mpi_snew(0);
-            /* gcry_mpi_scan( &mpi, GCRYMPI_FMT_STD, k, NULL, NULL ); */
-            gcr->err = gcry_ac_data_new(&keydata);
-            gcr->err = gcry_ac_data_set(keydata, GCRY_AC_FLAG_COPY, "s", mpi);
-            gcr->err = gcry_ac_key_init(&gcr->key_ac, gcr->h_ac, keytype, keydata);
+            croak("Asymmetric cryptography is not yet supported by Crypt::GCrypt");
         }
 
 void
@@ -796,7 +750,9 @@ cg_DESTROY(gcr)
     Crypt_GCrypt gcr;
     CODE:
         if (gcr->type == CG_TYPE_CIPHER) gcry_cipher_close(gcr->h);
+/*
         if (gcr->type == CG_TYPE_ASYMM)  gcry_ac_close(gcr->h_ac);
+*/
         if (gcr->type == CG_TYPE_DIGEST) gcry_md_close(gcr->h_md);
         
         if (gcr->need_to_call_finish == 1)
--- ./t/01-cipher.t.orig	2011-05-27 20:04:03.000000000 +0000
+++ ./t/01-cipher.t	2022-06-23 11:07:03.038721851 +0000
@@ -102,6 +102,7 @@ ok(substr($d, 0, length $p) eq $p)
                             algorithm => 'aes',
                             padding => 'none'
     );
+    $c->setkey($key);
     $c->start('encrypting');
     ok(!eval {my $e2 = $c->encrypt('aaa'); 1});  # this should die
     ok(eval { my $e2 = $c->encrypt('aaaaaaaaaaaaaaaa') . $c->finish; 1 });  # this should not die
openSUSE Build Service is sponsored by