using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace PkcsApp.Commands
{
    public class VerifyController : ApiController
    {

        // GET api/sign
        public string Get()
        {
            return "VerifyCommand";
        }

        // POST api/values 
        public string Post([FromBody]VerifyCommand value)
        {
            byte[] hash = HelperFunctions.HexStringToByte(value.hash);
            var tempCert = HelperFunctions.RemoveBeginEndCert(value.certificate);
            Certificate cert = new Certificate(Convert.FromBase64String(tempCert),"");
            byte[] signature = Convert.FromBase64String(value.signature);

            return cert.verifyHash(signature, hash, "SHA256").ToString();
        }
    }
}
