logo
down
shadow

Export Mac app using openssl 1.0.1j


Export Mac app using openssl 1.0.1j

By : user2957047
Date : November 22 2020, 03:03 PM
I wish this help you I have just begin develop app for Mac. , I'm apparently solve this problem:
code :
./Configure darwin64-x86_64-cc -shared --openssldir="@rpath"
install_name_tool -change /usr/lib/libcrypto.0.9.8.dylib\
 ../Frameworks/libcrypto.1.0.0.dylib BinaryName

install_name_tool -change /usr/lib/libssl.0.9.8.dylib\
 ../Frameworks/libssl.1.0.0.dylib BinaryName


Share : facebook icon twitter icon
How to export a public key in OpenSSL/libcrypto?

How to export a public key in OpenSSL/libcrypto?


By : user2333527
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You probably want the functions d2i_RSAPublicKey and i2d_RSAPublicKey. i2d serializes a RSA key struct to a bytestring, and d2i does the reverse operation.
C++ OpenSSL export private key

C++ OpenSSL export private key


By : user2858699
Date : March 29 2020, 07:55 AM
it helps some times See this forum posting here (snippet below):
code :
void AccessCard::PrivateKey(string& pem, const string& passphrase) const
{
    CheckKey();
    BioBox bio;
    bio.NewBuffer();

    EvpBox evp(keypair);
    int ret = PEM_write_bio_PKCS8PrivateKey(bio.Bio(), evp.Key(),
                                            EVP_aes_256_cbc(),
                                            LoseStringConst(passphrase),
                                            passphrase.size(), NULL, NULL);
    if (!ret)
        throw ReadError();
    const BioBox::Buffer& buf = bio.ReadAll();
    pem = string(reinterpret_cast<const char*>(buf.buf), buf.size);
}
#include <string>
#include <exception>
using std::string;

//typedef struct RSA;
#include <openssl/rsa.h>

class ReadError : public std::exception
{
public:
    virtual const char* what() const throw();
};

class NoKeypairLoaded : public std::exception
{
public:
    virtual const char* what() const throw();
};

class AccessCard
{
public:
    AccessCard();
    ~AccessCard();
    void Generate();
    void Load(const string& pem, const string& pass);
    void PublicKey(string& pem) const;
    void PrivateKey(string& pem, const string& passphrase) const;

private:
    void CheckKey() const;

    RSA* keypair;
};

class BioBox
{
public:
    struct Buffer
    {
        void* buf;
        int size;
    };

    BioBox();
    ~BioBox();
    void ConstructSink(const string& str);
    void NewBuffer();
    BIO* Bio() const;
    Buffer ReadAll();
private:
    BIO* bio;
    Buffer buf;
};

class EvpBox
{
public:
    EvpBox(RSA* keyp);
    ~EvpBox();
    EVP_PKEY* Key();
private:
    EVP_PKEY* evpkey;
};

//--------------------
#include <openssl/pem.h>

const char* ReadError::what() const throw()
{
    return "Problem reading BIO.";
}
const char* NoKeypairLoaded::what() const throw()
{
    return "No keypair loaded.";
}

AccessCard::AccessCard()
  : keypair(NULL)
{
    if (EVP_get_cipherbyname("aes-256-cbc") == NULL)
        OpenSSL_add_all_algorithms();
}
AccessCard::~AccessCard()
{
    RSA_free(keypair);
}
void AccessCard::CheckKey() const
{
    if (!keypair)
        throw NoKeypairLoaded();
}

void AccessCard::Generate()
{
    RSA_free(keypair);
    keypair = RSA_generate_key(2048, RSA_F4, NULL, NULL);
    CheckKey();
}

static char *LoseStringConst(const string& str)
{
    return const_cast<char*>(str.c_str());
}
static void* StringAsVoid(const string& str)
{
    return reinterpret_cast<void*>(LoseStringConst(str));
}

BioBox::BioBox()
 : bio(NULL)
{
    buf.buf = NULL;
    buf.size = 0;
}
BioBox::~BioBox()
{
    BIO_free(bio);
    free(buf.buf);
}
void BioBox::ConstructSink(const string& str)
{
    BIO_free(bio);
    bio = BIO_new_mem_buf(StringAsVoid(str), -1);
    if (!bio)
        throw ReadError();
}
void BioBox::NewBuffer()
{
    BIO_free(bio);
    bio = BIO_new(BIO_s_mem());
    if (!bio)
        throw ReadError();
}
BIO* BioBox::Bio() const
{
    return bio;
}
BioBox::Buffer BioBox::ReadAll()
{
    buf.size = BIO_ctrl_pending(bio);
    buf.buf = malloc(buf.size);
    if (BIO_read(bio, buf.buf, buf.size) < 0) {
        //if (ERR_peek_error()) {
        //    ERR_reason_error_string(ERR_get_error());
        //    return NULL;
        //}
        throw ReadError();
    }
    return buf;
}

EvpBox::EvpBox(RSA* keyp)
{
    evpkey = EVP_PKEY_new();
    if (!EVP_PKEY_set1_RSA(evpkey, keyp)) {
        throw ReadError();
    }
}
EvpBox::~EvpBox()
{
    EVP_PKEY_free(evpkey);
}
EVP_PKEY* EvpBox::Key()
{
    return evpkey;
}

static int pass_cb(char* buf, int size, int rwflag, void* u)
{
    const string pass = reinterpret_cast<char*>(u);
    int len = pass.size();
    // if too long, truncate
    if (len > size)
        len = size;
    pass.copy(buf, len);
    return len;
}
void AccessCard::Load(const string& pem, const string& pass)
{
    RSA_free(keypair);
    BioBox bio;
    bio.ConstructSink(pem);
    keypair = PEM_read_bio_RSAPrivateKey(bio.Bio(), NULL, pass_cb,
                                         StringAsVoid(pass));
    CheckKey();                     
}
void AccessCard::PublicKey(string& pem) const
{
    CheckKey();
    BioBox bio;
    bio.NewBuffer();
    int ret = PEM_write_bio_RSA_PUBKEY(bio.Bio(), keypair);
    if (!ret)
        throw ReadError();
    const BioBox::Buffer& buf = bio.ReadAll();
    pem = string(reinterpret_cast<const char*>(buf.buf), buf.size);
}

void AccessCard::PrivateKey(string& pem, const string& passphrase) const
{
    CheckKey();
    BioBox bio;
    bio.NewBuffer();

    EvpBox evp(keypair);
    int ret = PEM_write_bio_PKCS8PrivateKey(bio.Bio(), evp.Key(),
                                            EVP_aes_256_cbc(),
                                            LoseStringConst(passphrase),
                                            passphrase.size(), NULL, NULL);
    if (!ret)
        throw ReadError();
    const BioBox::Buffer& buf = bio.ReadAll();
    pem = string(reinterpret_cast<const char*>(buf.buf), buf.size);
}

//-------------------------------------------------------------------
// this wont be in the final file... it's our unit test
//-------------------------------------------------------------------
#include <iostream>
#include <assert.h>
using std::cout;

int main()
{
    AccessCard acc;                                                    
    // New key
    acc.Generate();
    string pem;
    // Get public key
    acc.PublicKey(pem);
    cout << pem << "\n";
    // Get private key
    acc.PrivateKey(pem, "hello");
    cout << pem << "\n";
    // Load a private key using pass 'hello'
    acc.Load(pem, "hello");
    acc.PublicKey(pem);
    cout << pem << "\n";
    return 0;
}
openssl create rsa key pair in C and export it

openssl create rsa key pair in C and export it


By : JoeXu
Date : March 29 2020, 07:55 AM
hope this fix your issue If you really need the PEM representation, then PEM_write_bio_RSA_PUBKEY() and PEM_write_bio_RSAPrivateKey() (along with their read counterparts) are the functions you want; give them memory BIOs to have them write into a memory buffer.
You can create a memory BIO by invoking e.g.
code :
BIO * b = BIO_new(BIO_s_mem());
void * buf;
BIO_get_mem_ptr(b, &buf);
BIO * b = BIO_new_mem_buf(buf, 9001)
Export openssl key to file

Export openssl key to file


By : JuanJo Yanes
Date : March 29 2020, 07:55 AM
Hope this helps I generated a private key using commend: , You need to generate an crt file too.
code :
openssl req -x509 -nodes -newkey rsa:2048 -days 1825 -out cert.crt -keyout key.key
openssl pkcs12 -export -inkey key.key -in cert.crt -out export.p12
openssl pkcs12 -export -inkey key.key -in cert.crt -certfile ca.crt -out export.p12
Export OpenSSL public key to file

Export OpenSSL public key to file


By : user3276715
Date : March 29 2020, 07:55 AM
will be helpful for those in need That's the solution. to https://www.virendrachandak.com/techtalk/encryption-using-php-openssl/
code :
// Generate the public key for the private key
$key = openssl_pkey_get_details($privateKey); // $privateKey is created with openssl_pkey_new()

// Save the public key in public.pem file
file_put_contents('public.pem', $key['key']);
Related Posts Related Posts :
  • How to generate XCode project on Mac with node-gyp
  • Running App on ios7
  • Google Test and XCode 4.6
  • Swift - Unable to open file in target Xcode 10
  • A build error occurred when I used Xcode to compile a example 'sync_client' of boost
  • How can I copy/sync the Xcode "Link Library with Libraries" phase between different build targets
  • Swift: Why is my completionHandler closure returning a value?
  • Calling a string through a function using an array and UITableView as indicator
  • Subclassing in Swift SpriteKit
  • Thread 1: signal SIGABRT Xcode 6.1
  • How to derive multiple classes from a single nib
  • Cant get map preview to load in Watchkit 6.2 Beta using Swift
  • how to instantiate an NSLayoutConstraint in swift? (Xcode 6.1.1)
  • How do I open/close this panel in IB?
  • NSURL bookmarks failing in unit tests on Xcode Server
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org