C# equivalent of openssl ecparam -name prime256v1 -genkey -noout -out I am having some issues generating a proper private key,I need it to be an  Elliptic Curve private key suitable for use with NIST P-256 which i than need to  convert to Base64-encoded private key in PKCS #8, for some reason when I generate the key and than base64 encode the bytes I end up with a string of 108 characters. but I need it to be in the range of 184 characters. The following is what I am doing with bouncy castle, I am aware that this is more of a crypto section but also just knowing the steps of what it is I need to properly do would be appreciated from a non programming level 

       // Curve Cryptography (ECC) key pair.
        DerObjectIdentifier ecParam = new 
        DerObjectIdentifier("1.2.840.10045.3.1.7");
        ECKeyPairGenerator keyGen = new ECKeyPairGenerator();
        keyGen.Init(new ECKeyGenerationParameters(ecParam, new 
        SecureRandom()));
        AsymmetricCipherKeyPair keyPairServer = keyGen.GenerateKeyPair();

        //Grab private key from key pair 
        // for storing. 
        PrivateKeyInfo pkInfo = 
        PrivateKeyInfoFactory.CreatePrivateKeyInfo(keyPairServer.Private);
        String privateKey = Convert.ToBase64String(pkInfo.GetDerEncoded());
Your question is contradictory and incomplete, as well as being primarily about coding for a particular implementation, which is offtopic and apparently heading (slowly) for closure.

First, the output from openssl ecparam -genkey is NOT PKCS8 format (not either of them); it is the algorithm-specific format from SEC1 (available at http://www.secg.org)(*) including the public point (tagged context[1]) as well as the curve (context[0]). For P256/secp256r1/prime256v1 (in named form) this is 121 bytes in DER if the public point is uncompressed (as is default) and 89 bytes if compressed; in base64 these are 164 and 120 characters and in PEM they are 227 and 182 chars using LF for linebreak or 232 and 186 using CRLF. 

Second, the output from that openssl commandline operation, like most others including the ones that are in PKCS8 format, is by default PEM. PEM is NOT just base64 of DER, as you coded; it is base64 of DER PLUS linebreaks PLUS header and trailer, which are important and among other things change the length.

Although I don't have dotnet set up to test, according to the source that BouncyCastle call does produce PKCS8 (unencrypted) 'wrapping' SEC1 (class ECPrivateKeyStructure is in Org.Bouncycastle.Asn1.Sec) with the 
curve (which is redundant here) but NOT the public point (see currently line 142, and similarly 126 for ECGOST). That will be 80 bytes DER, 108 chars base64, or 164 or 168 chars PEM. BouncyCastle also has classes to write and read PEM although unencrypted PEM is simple enough you can do it by hand.

If you can specify more exactly what you want, or at least how (and by what software) the result will be used, and thus how it differs from what you have, this will probably be ontopic for StackOverflow or maybe security.SX (which does accept some how-to-code-crypto Qs).

(*) Ironically, secg is currently serving HTTPS with an invalid cert, and so is best accessed HTTP!