public string Firmar(ref authTokenType token, string texto, string alias, SignatureModeType tipodefirma) { LunaXml.xmCryptoService client = new xmCryptoService(); try { sign textoafirmar = new sign(); textoafirmar.AuthToken = token; textoafirmar.SignatureModeSpecified = true; textoafirmar.DataToSign = Convert.ToBase64String(Encoding.UTF8.GetBytes(texto)); textoafirmar.SignatureMode = tipodefirma; textoafirmar.SigningKeyAlias = alias; signResponse respuesta = client.sign(textoafirmar); token = respuesta.AuthToken; if (respuesta.Result.ResultMajor != null && respuesta.Result.ResultMajor == "urn:oasis:names:tc:dss:resultmajor:Success") { return(respuesta.Signature); } else { Log.Error((respuesta.Result.ResultMessage != null ? respuesta.Result.ResultMessage.Value : "")); return(null); } } catch (Exception ex) { Log.Error("Error al intentar firmar: " + ex); return(null); } finally { client.Dispose(); } }
public CryptoConfig(IKdfConfig kdfConfig, CipherModeType cipherMode, IvGenerationModeType ivGenerationMode, SignatureModeType signatureMode) { KdfConfig = kdfConfig; CipherMode = cipherMode; IvGenerationMode = ivGenerationMode; SignatureMode = signatureMode; }