Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:17:43+00:00 2026-06-17T06:17:43+00:00

I am trying to write a simple RSA encryption scheme to encrypt a small

  • 0

I am trying to write a simple RSA encryption scheme to encrypt a small message between a single server and potentially many clients.

The plan I have come up with is to have the client generate a key pair and send the public key to the server. The server has an object that will store the socket and the public key. When it comes time to send the message the server will call a method in the Client object that will encrypt the message and send it down to the client.

I will only be encrypting the messages going to the client, so I don’t need to worry about a full transaction of keys.

I think I have that pretty well figured out.

The problems are coming from trying to connect two different implementations of RSA. The server is written in C# and the client is a MetaTrader client using C. I have decided to use OpenSSL to try to bridge the gap, but so far I haven’t been able to produce a key on the client. I am using the openssl wrapper for c# (http://openssl-net.sourceforge.net/) and I am trying to write a very basic wrapper dll for MetaTrader. So far it contains two functions, GenerateRSAKeys and DecryptRSA.

For now, I would just like to produce a PEM formatted string that contains the public key. This is what I have so far for GenerateRSAKeys().

extern "C" unsigned char *__stdcall GenerateRSAKeys (){

int len;
unsigned char *buf = new unsigned char[1024];

rsa = RSA_generate_key(512,RSA_F4,NULL,NULL);

len=i2d_RSAPublicKey(rsa, &buf);

return buf;}

Right now, when sending buf to the server I receive a single character. Such as, “X”

So my first question is, what is the best way to export the generated public key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:17:45+00:00Added an answer on June 17, 2026 at 6:17 am

    You are returning a pointer to a buffer allocated on the stack; this buffer will be overwritten when the function returns. Try buf = new unsigned char[1024];

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write simple proxy server for some purpose. In it I use
Im trying to write a simple scheme function that returns the last element of
i'm trying to write simple C openssl client and server. Here is client's code:
I’m trying to write a simple encryption routine in C using OpenSSL and I’ve
Was trying to write simple client and server recieveing/sending data through TMemoryStream . When
I'm trying to write simple client and server C programs, communicating with each other
I'm trying to write simple app, which sends short text message to cellphones in
i'm trying to write simple tcp\ip client-server. here is server code: internal class Program
i have a weird problem. I am trying to write simple Client - Server
I'm trying to write a simple python web application using the Tornado web server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.