int RSA_load_private_key_from_buffer(pri_key *prikey, char *source, int sourceLen) {
    char temp[buffer_size];
    char temp2[buffer_size];
    int  result;

    //1. take out the header and the bottom certificate string
    result = sourceLen - (key_top_length + key_bottom_length + crlf_length + crlf_length);

    if ((result <= 0) || (result > buffer_size))
        return 0;
    if (key_top_length + crlf_length > sourceLen)
        return 0;

    memcpy(temp, source + key_top_length + crlf_length, result);

    //2. decode PEM
    result = PEM_decode(temp, temp2, result, buffer_size);
    if (result == 0)
        return 0;

    //3. convert buffer to structure
    result = load_private_key_structure_from_buffer(prikey, temp2, result);
    if (result == 0)
        return 0;

    return 1;
}
예제 #2
0
/*
* DL_Group Constructor
*/
DL_Group::DL_Group(const std::string& name)
   {
   const char* pem = PEM_for_named_group(name);

   if(!pem)
      throw Invalid_Argument("DL_Group: Unknown group " + name);

   PEM_decode(pem);
   }