Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 3b4f1f302dd1d3a8b71d82bf3900802945a0b431 authored by Dr. Stephen Henson on 19 October 2012, 20:53:35 UTC, committed by Dr. Stephen Henson on 19 October 2012, 20:53:35 UTC
update DRBG to handle new file format
1 parent 986b927
  • Files
  • Changes
  • c17d657
  • /
  • demos
  • /
  • maurice
  • /
  • example2.c
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:3b4f1f302dd1d3a8b71d82bf3900802945a0b431 into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:3b4f1f302dd1d3a8b71d82bf3900802945a0b431 as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:3b4f1f302dd1d3a8b71d82bf3900802945a0b431
content badge Iframe embedding
swh:1:cnt:57bce10b5ed5ec37f8ee1d3a37b0394604732752
example2.c
/* NOCW */
/*
        Please read the README file for condition of use, before
        using this software.

        Maurice Gittens  <mgittens@gits.nl>   January 1997
*/

#include <stdlib.h>
#include <stdio.h>
#include <strings.h>

#include <openssl/rsa.h>
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/x509.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>

#include "loadkeys.h"

#define PUBFILE   "cert.pem"
#define PRIVFILE  "privkey.pem"
#define STDIN     0
#define STDOUT    1 

int main()
{
        char *ct = "This the clear text";
	char *buf;   
	char *buf2;
  	EVP_PKEY *pubKey;
  	EVP_PKEY *privKey;
	int len;

        ERR_load_crypto_strings();

        privKey = ReadPrivateKey(PRIVFILE);
        if (!privKey) 
	{  
		ERR_print_errors_fp (stderr);    
		exit (1);  
	}

        pubKey = ReadPublicKey(PUBFILE);  
	if(!pubKey)
	{
	   EVP_PKEY_free(privKey);   
           fprintf(stderr,"Error: can't load public key");
	   exit(1);
	}

	/* No error checking */
        buf = malloc(EVP_PKEY_size(pubKey));
        buf2 = malloc(EVP_PKEY_size(pubKey));

	len = RSA_public_encrypt(strlen(ct)+1, ct, buf, pubKey->pkey.rsa,RSA_PKCS1_PADDING);

	if (len != EVP_PKEY_size(pubKey))
	{
	    fprintf(stderr,"Error: ciphertext should match length of key\n");
	    exit(1);
	}

	RSA_private_decrypt(len, buf, buf2, privKey->pkey.rsa,RSA_PKCS1_PADDING);

	printf("%s\n", buf2);

	EVP_PKEY_free(privKey);
	EVP_PKEY_free(pubKey);
	free(buf);
	free(buf2);
        return 0;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top