+ return status;
+#elif defined HAVE_OPENSSL
+ X509_STORE *store = NULL;
+ PKCS7 *p7 = NULL;
+ BIO *in = NULL, *indata = NULL;
+
+ // Sig check failed by default !
+ int status = -1;
+
+ init_openssl();
+
+ // Set-up the key store
+ if(!(store = setup_verify(conf, conf->signature_ca_file, conf->signature_ca_path))){
+ opkg_message(conf, OPKG_ERROR,
+ "Can't open CA certificates\n");
+ goto verify_file_end;
+ }
+
+ // Open a BIO to read the sig file
+ if (!(in = BIO_new_file(sig_file, "rb"))){
+ opkg_message(conf, OPKG_ERROR,
+ "Can't open signature file %s\n", sig_file);
+ goto verify_file_end;
+ }
+
+ // Read the PKCS7 block contained in the sig file
+ p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL);
+ if(!p7){
+ opkg_message(conf, OPKG_ERROR,
+ "Can't read signature file (Corrupted ?)\n");
+ goto verify_file_end;
+ }
+
+ // Open the Package file to authenticate
+ if (!(indata = BIO_new_file(text_file, "rb"))){
+ opkg_message(conf, OPKG_ERROR,
+ "Can't open file %s\n", text_file);
+ goto verify_file_end;
+ }
+
+ // Let's verify the autenticity !
+ if (PKCS7_verify(p7, NULL, store, indata, NULL, PKCS7_BINARY) != 1){
+ // Get Off My Lawn!
+ opkg_message(conf, OPKG_ERROR,
+ "Verification failure\n");
+ }else{
+ // Victory !
+ status = 0;
+ }
+
+verify_file_end:
+ BIO_free(in);
+ BIO_free(indata);
+ PKCS7_free(p7);
+ X509_STORE_free(store);
+