https://www.cryptopro.ru...aspx?g=posts&t=22487Имя алгоритма поменял. В остальном код соответствует и поведение соответствует тому, что описано по ссылке.
Пример. Получим подпись для строки "This is CryptoPro GOST43 algorithm test!")
На вашем сайте(https://cryptopro.ru/sites/default/files/products/cades/demopage/cades_bes_sample.html#) была сгенерирована следующая подпись:
MIIHIQYJKoZIhvcNAQcCoIIHEjCCBw4CAQExCzAJBgUrDgMCGgUAMDcGCSqGSIb3DQEHAaAqBChU
aGlzIGlzIENyeXB0b1BybyBHT1NUNDMgYWxnb3JpdGhtIHRlc3QhoIID6DCCA+QwggLMoAMCAQIC
EC9DNmyenMW9RdQnbgz5GfcwDQYJKoZIhvcNAQELBQAwZzErMCkGA1UECwwiQ3JlYXRlZCBieSBo
dHRwOi8vd3d3LmZpZGRsZXIyLmNvbTEVMBMGA1UECgwMRE9fTk9UX1RSVVNUMSEwHwYDVQQDDBhE
T19OT1RfVFJVU1RfRmlkZGxlclJvb3QwHhcNMjMwOTA5MDI1MjI3WhcNMjQwOTA4MDI1MjI3WjBm
MSswKQYDVQQLDCJDcmVhdGVkIGJ5IGh0dHA6Ly93d3cuZmlkZGxlcjIuY29tMRUwEwYDVQQKDAxE
T19OT1RfVFJVU1QxIDAeBgNVBAMMFyouZmxpZ2h0cHJveHkuc2t5cGUuY29tMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtPCih5enjF3oYF/q1trznjno/5RA59TvoJGqYmsKXVdryOIU
Gomm0XmelavwisbSb8riwai6Vl2u8feeW5nqIVLjkvynGsILZiaOK8b2E3g5SYYzVAnZPanutnlb
dOCuMXWFeelbs/JOp8PUfQNigG4zmP5kvwk4nOLRtSZpf6vJuEJv8bGYXTBY8T9TFFO+BORrkUn3
FLacuZKkfjSyhC47AwjVdUh3G9mvIoLOM2WbKWhhoyJuplKuE91kW4BW7x7/nQ66TWysN2EoNF5u
BJyPbuOVZeKYke8zlstuUj4HXBfrcKT0A3z4dc5YVrwqUqc7F4Zq9Y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DovL3d3dy5maWRkbGVyMi5jb20xFTAT
BgNVBAoMDERPX05PVF9UUlVTVDEhMB8GA1UEAwwYRE9fTk9UX1RSVVNUX0ZpZGRsZXJSb290AhAv
QzZsnpzFvUXUJ24M+Rn3MA0GCSqGSIb3DQEBAQUABIIBAKYoIPdKnsjFPb1hB741cqY/MrJibvw5
iK45TYsAcJ+au9vDLa+XoKKBnJJhOCREKXZBOfm/MPzEvyU6CKACFFl8uWz813X7npBrveZz3Hac
oemaAKMRvdOC+wuU8H0S0H7V+6BMerNn33n3xI89+fDFlcxNXNTj5TsRapztDUtwIrqf52xFwHpR
eL3YdpcnQrNOtgYq9svDv18u3q+GcGNW7E/U8Ww53vPEAbomKYyNIVa+/2u9zmVqyCRor5NMT2+K
lc9673CcA0c0NKGGmznBgtnO2W+S1r0PyNcq0OQUFN7x76i+UMW9xzMwH5yfzsc2Wl7zWUz9HTKv
l3FlA9Y=
Во результат вычисления подписи повторно, по той же ссылке:
MIIHIQYJKoZIhvcNAQcCoIIHEjCCBw4CAQExCzAJBgUrDgMCGgUAMDcGCSqGSIb3DQEHAaAqBChU
aGlzIGlzIENyeXB0b1BybyBHT1NUNDMgYWxnb3JpdGhtIHRlc3QhoIID6DCCA+QwggLMoAMCAQIC
EC9DNmyenMW9RdQnbgz5GfcwDQYJKoZIhvcNAQELBQAwZzErMCkGA1UECwwiQ3JlYXRlZCBieSBo
dHRwOi8vd3d3LmZpZGRsZXIyLmNvbTEVMBMGA1UECgwMRE9fTk9UX1RSVVNUMSEwHwYDVQQDDBhE
T19OT1RfVFJVU1RfRmlkZGxlclJvb3QwHhcNMjMwOTA5MDI1MjI3WhcNMjQwOTA4MDI1MjI3WjBm
MSswKQYDVQQLDCJDcmVhdGVkIGJ5IGh0dHA6Ly93d3cuZmlkZGxlcjIuY29tMRUwEwYDVQQKDAxE
T19OT1RfVFJVU1QxIDAeBgNVBAMMFyouZmxpZ2h0cHJveHkuc2t5cGUuY29tMIIBIjANBgkqhkiG
9w0BA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bc14ArAPT6zhOjnNCCQViS3+pq0UmEbqYOjMYbnhdX01adQ567rCEzcXeV7M
yC1It+L1tA==
То есть, как считать эту самую подпись, непонятно
Я смотрел ваши примеры. Я реализовал код метода createCMSEx из файла CMS.java
Результат приведен выше. На вход метода в параметре buffer был передан результат следующего вычисления:
Код:private byte[] signMessage(String algoName, PrivateKey privateKey, String msg) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
Signature signer = Signature.getInstance(algoName, JCP.PROVIDER_NAME);
signer.initSign(privateKey);
signer.update(msg.getBytes());
return signer.sign();
}
Видно, что если первые две подписи отличаются минимально, как я понимаю - отличается имитовставка, то подпись вычисленная в java коде отличается сильно.
Поэтому, далее войти на сайт не получается, так как подпись не опознаётся сайтом.