Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSA签名计算失败 #1

Open
heidawei opened this issue Feb 26, 2016 · 2 comments
Open

RSA签名计算失败 #1

heidawei opened this issue Feb 26, 2016 · 2 comments

Comments

@heidawei
Copy link

我使用两组不同的密钥测试,发现第一组在签名计算时就返回错误,第二组是可以成功的。
/*
var publicKey = []byte(-----BEGIN PUBLIC KEY----- MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAMnq1wtxSjuMRPKULlvJxx//CQWKxqx2 TzGHDmOQZVT/AgMBAAE= -----END PUBLIC KEY-----)

var privateKey = []byte(-----BEGIN RSA PRIVATE KEY----- MIGrAgEAAiEAyerXC3FKO4xE8pQuW8nHH/8JBYrGrHZPMYcOY5BlVP8CAwEAAQIg HNTpq/qbTPF0jubVz8l6IziHlW5rHt3r8etpnTZMuRECEQDob9bD+4LzwtK+1AJy YPL7AhEA3mL2sjTi5vp0y04BC1ymzQIRALIl9d9kB+w4qDnmWLG9qL0CEQDJ0P/W e95LBZIGipSyDfQlAhBaDYtiehP+XMDPcv/x9Kj0 -----END RSA PRIVATE KEY-----)
*/

var publicKey = []byte(-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3 6rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6 Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJw oYi+1hqp1fIekaxsyQIDAQAB -----END PUBLIC KEY-----)

var privateKey = []byte(-----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u 412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI 7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== -----END RSA PRIVATE KEY-----)
从密钥长度上看这两组密钥的长度不一样,但都是可用的密钥,不清楚为什么第一组不可以

@89hmdys
Copy link
Owner

89hmdys commented Jun 24, 2016

嘛,能附上你的测试代码吗?

@89hmdys
Copy link
Owner

89hmdys commented Jun 24, 2016

感觉可能是因为秘钥格式不同,LoadKeyFromPEMFile第三个参数决定了按照何种格式来转换密码,文档里写的是PKCS8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants