A RSA key pair consist in the following:
- The modulus n, a big integer which is equal to the product of two big prime integers, p and q.
- The public exponent e.
- The private exponent d. d is such that ed = 1 when taken modulo p-1, and also when taken modulo q-1.
- The first factor p.
- The second factor q.
- The value dp = d mod p-1.
- The value dq = d mod q-1.
- The value q' = q-1 mod p.
The public key contains only n and e.
The private key contains all of the values specified above. Stricto sensu, only n and d are needed for a perfunctory RSA implementation, but the other values allow for faster operation, and also "masking" (protection against side-channel leaks), so the RSA standard defines that a private key contains all the values (see appendix A.1).
From the value you have, assuming that your "m" is really the RSA modulus, the other values can be recomputed, at some effort (less than one second worth of CPU, but more human time than I care to invest in it). From all these values, you could then encode standard-compliant RSA public and private keys; but this requires some knowledge of ASN.1. Finally, a 512-bit RSA key is weak; use at least 1024 bits, preferably more (2048 bits ought to be fine). Some RSA implementations will refuse to work with RSA keys shorter than 1024 bits.
Bottom-line: don't generate the key yourself; use OpenSSL. With the command-line tool:
openssl genrsa -out rsakey.pem 2048
will generate a 2048-bit RSA private key with all the proper encoding; then this:
openssl rsa -in rsakey.pem -pubout
will print out the public key, there again with the encoding done.