      std::shared_ptr<EC_Group_Data> lookup_or_create(const BigInt& p,
                                                      const BigInt& a,
                                                      const BigInt& b,
                                                      const BigInt& g_x,
                                                      const BigInt& g_y,
                                                      const BigInt& order,
                                                      const BigInt& cofactor,
                                                      const OID& oid)
         {
         lock_guard_type<mutex_type> lock(m_mutex);

         for(auto i : m_registered_curves)
            {
            if(oid.has_value())
               {
               if(i->oid() == oid)
                  return i;
               else if(i->oid().has_value())
                  continue;
               }

            if(i->match(p, a, b, g_x, g_y, order, cofactor))
               return i;
            }

         // Not found - if OID is set try looking up that way

         if(oid.has_value())
            {
            // Not located in existing store - try hardcoded data set
            std::shared_ptr<EC_Group_Data> data = EC_Group::EC_group_info(oid);

            if(data)
               {
               m_registered_curves.push_back(data);
               return data;
               }
            }

         // Not found or no OID, add data and return
         return add_curve(p, a, b, g_x, g_y, order, cofactor, oid);
         }
      std::shared_ptr<EC_Group_Data> lookup_or_create(const BigInt& p,
                                                      const BigInt& a,
                                                      const BigInt& b,
                                                      const BigInt& g_x,
                                                      const BigInt& g_y,
                                                      const BigInt& order,
                                                      const BigInt& cofactor,
                                                      const OID& oid)
         {
         lock_guard_type<mutex_type> lock(m_mutex);

         for(auto i : m_registered_curves)
            {
            if(oid.has_value())
               {
               if(i->oid() == oid)
                  return i;
               else if(i->oid().has_value())
                  continue;
               }

            if(i->match(p, a, b, g_x, g_y, order, cofactor))
               return i;
            }

          

         if(oid.has_value())
            {
             
            std::shared_ptr<EC_Group_Data> data = EC_Group::EC_group_info(oid);

            if(data)
               {
               m_registered_curves.push_back(data);
               return data;
               }
            }

          
         return add_curve(p, a, b, g_x, g_y, order, cofactor, oid);
         }