Add SHAKE and CSHAKE (#90)
* Refactor digests to use SymcryptHash* functions * Additional refactor and add SHAKE * Bump version * Add CSHAKE * Add MD testing and fix uncovered bugs * Delay init and restrict parameters during update operation * Cleanup * Put digest squeeze behind ifdef * Move new parameter names to separate file * Don't dynamically alloc cshake state * Rename function name string parameter * PR comments * Init in extract if update has not been called * Track cshake state in provider
This commit is contained in:
Родитель
7a7215d3ad
Коммит
98749e496d
|
@ -0,0 +1,208 @@
|
||||||
|
#
|
||||||
|
# Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
# in the file LICENSE in the source distribution or at
|
||||||
|
# https://www.openssl.org/source/license.html
|
||||||
|
|
||||||
|
# Tests start with one of these keywords
|
||||||
|
# Cipher Decrypt Derive Digest Encoding KDF MAC PBE
|
||||||
|
# PrivPubKeyPair Sign Verify VerifyRecover
|
||||||
|
# and continue until a blank line. Lines starting with a pound sign are ignored.
|
||||||
|
|
||||||
|
|
||||||
|
Title = SHA tests from (RFC6234 section 8.5 and others)
|
||||||
|
|
||||||
|
Digest = SHA1
|
||||||
|
Input = "abc"
|
||||||
|
Output = a9993e364706816aba3e25717850c26c9cd0d89d
|
||||||
|
|
||||||
|
Digest = SHA1
|
||||||
|
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||||
|
Output = 84983e441c3bd26ebaae4aa1f95129e5e54670f1
|
||||||
|
|
||||||
|
Digest = SHA1
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 1000
|
||||||
|
Count = 1000
|
||||||
|
Output = 34aa973cd4c4daa4f61eeb2bdbad27316534016f
|
||||||
|
|
||||||
|
Digest = SHA256
|
||||||
|
Input = "abc"
|
||||||
|
Output = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
|
||||||
|
|
||||||
|
Digest = SHA256
|
||||||
|
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||||
|
Output = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
|
||||||
|
|
||||||
|
Digest = SHA256
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 288
|
||||||
|
Count = 3472
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 64
|
||||||
|
Output = cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0
|
||||||
|
|
||||||
|
Digest = SHA384
|
||||||
|
Input = "abc"
|
||||||
|
Output = cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7
|
||||||
|
|
||||||
|
Digest = SHA384
|
||||||
|
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
|
||||||
|
Output = 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
|
||||||
|
|
||||||
|
Digest = SHA384
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 64
|
||||||
|
Count = 15625
|
||||||
|
Output = 9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985
|
||||||
|
|
||||||
|
Digest = SHA512
|
||||||
|
Input = "abc"
|
||||||
|
Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
|
||||||
|
|
||||||
|
Digest = SHA512
|
||||||
|
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
|
||||||
|
Output = 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
|
||||||
|
|
||||||
|
Digest = SHA512
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 288
|
||||||
|
Count = 3472
|
||||||
|
Input = "a"
|
||||||
|
Ncopy = 64
|
||||||
|
Output = e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b
|
||||||
|
|
||||||
|
Title = SHA3
|
||||||
|
|
||||||
|
# Empty input and \xA3x200 vectors are taken from
|
||||||
|
# http://csrc.nist.gov/groups/ST/toolkit/examples.html#aHashing
|
||||||
|
# Others are pairs of "LongMsg" vectors available at
|
||||||
|
# http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html#test-vectors
|
||||||
|
|
||||||
|
Digest = SHA3-256
|
||||||
|
Input = ""
|
||||||
|
Output = A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A
|
||||||
|
|
||||||
|
Digest = SHA3-256
|
||||||
|
Input = A3
|
||||||
|
Count = 200
|
||||||
|
Output = 79F38ADEC5C20307A98EF76E8324AFBFD46CFD81B22E3973C65FA1BD9DE31787
|
||||||
|
|
||||||
|
Digest = SHA3-256
|
||||||
|
Input = b1caa396771a09a1db9bc20543e988e359d47c2a616417bbca1b62cb02796a888fc6eeff5c0b5c3d5062fcb4256f6ae1782f492c1cf03610b4a1fb7b814c057878e1190b9835425c7a4a0e182ad1f91535ed2a35033a5d8c670e21c575ff43c194a58a82d4a1a44881dd61f9f8161fc6b998860cbe4975780be93b6f87980bad0a99aa2cb7556b478ca35d1f3746c33e2bb7c47af426641cc7bbb3425e2144820345e1d0ea5b7da2c3236a52906acdc3b4d34e474dd714c0c40bf006a3a1d889a632983814bbc4a14fe5f159aa89249e7c738b3b73666bac2a615a83fd21ae0a1ce7352ade7b278b587158fd2fabb217aa1fe31d0bda53272045598015a8ae4d8cec226fefa58daa05500906c4d85e7567
|
||||||
|
Output = cb5648a1d61c6c5bdacd96f81c9591debc3950dcf658145b8d996570ba881a05
|
||||||
|
|
||||||
|
Digest = SHA3-256
|
||||||
|
Input = 712b03d9ebe78d3a032a612939c518a6166ca9a161183a7596aa35b294d19d1f962da3ff64b57494cb5656e24adcf3b50e16f4e52135d2d9de76e94aa801cf49db10e384035329c54c9455bb3a9725fd9a44f44cb9078d18d3783d46ce372c31281aecef2f8b53d5702b863d71bc5786a33dd15d9256103b5ff7572f703d5cde6695e6c84f239acd1d6512ef581330590f4ab2a114ea064a693d5f8df5d908587bc7f998cde4a8b43d8821595566597dc8b3bf9ea78b154bd8907ee6c5d4d8a851f94be510962292b7ddda04d17b79fab4c022deb400e5489639dbc448f573d5cf72073a8001b36f73ac6677351b39d9bdb900e9a1121f488a7fa0aee60682e7dc7c531c85ec0154593ded3ae70e4121cae58445d8896b549cacf22d07cdace7625d57158721b44851d796d6511c38dac28dd37cbf2d7073b407fbc813149adc485e3dacee66755443c389d2d90dc70d8ff91816c0c5d7adbad7e30772a1f3ce76c72a6a2284ec7f174aefb6e9a895c118717999421b470a9665d2728c3c60c6d3e048d58b43c0d1b5b2f00be8b64bfe453d1e8fadf5699331f9
|
||||||
|
Output = 095dcd0bc55206d2e1e715fb7173fc16a81979f278495dfc69a6d8f3174eba5a
|
||||||
|
|
||||||
|
|
||||||
|
Digest = SHA3-384
|
||||||
|
Input = ""
|
||||||
|
Output = 0C63A75B845E4F7D01107D852E4C2485C51A50AAAA94FC61995E71BBEE983A2AC3713831264ADB47FB6BD1E058D5F004
|
||||||
|
|
||||||
|
Digest = SHA3-384
|
||||||
|
Input = A3
|
||||||
|
Count = 200
|
||||||
|
Output = 1881DE2CA7E41EF95DC4732B8F5F002B189CC1E42B74168ED1732649CE1DBCDD76197A31FD55EE989F2D7050DD473E8F
|
||||||
|
|
||||||
|
Digest = SHA3-384
|
||||||
|
Input = 5fe35923b4e0af7dd24971812a58425519850a506dfa9b0d254795be785786c319a2567cbaa5e35bcf8fe83d943e23fa5169b73adc1fcf8b607084b15e6a013df147e46256e4e803ab75c110f77848136be7d806e8b2f868c16c3a90c14463407038cb7d9285079ef162c6a45cedf9c9f066375c969b5fcbcda37f02aacff4f31cded3767570885426bebd9eca877e44674e9ae2f0c24cdd0e7e1aaf1ff2fe7f80a1c4f5078eb34cd4f06fa94a2d1eab5806ca43fd0f06c60b63d5402b95c70c21ea65a151c5cfaf8262a46be3c722264b
|
||||||
|
Output = 3054d249f916a6039b2a9c3ebec1418791a0608a170e6d36486035e5f92635eaba98072a85373cb54e2ae3f982ce132b
|
||||||
|
|
||||||
|
Digest = SHA3-384
|
||||||
|
Input = 035adcb639e5f28bb5c88658f45c1ce0be16e7dafe083b98d0ab45e8dcdbfa38e3234dfd973ba555b0cf8eea3c82ae1a3633fc565b7f2cc839876d3989f35731be371f60de140e3c916231ec780e5165bf5f25d3f67dc73a1c33655dfdf439dfbf1cbba8b779158a810ad7244f06ec078120cd18760af436a238941ce1e687880b5c879dc971a285a74ee85c6a746749a30159ee842e9b03f31d613dddd22975cd7fed06bd049d772cb6cc5a705faa734e87321dc8f2a4ea366a368a98bf06ee2b0b54ac3a3aeea637caebe70ad09ccda93cc06de95df73394a87ac9bbb5083a4d8a2458e91c7d5bf113aecae0ce279fdda76ba690787d26345e94c3edbc16a35c83c4d071b132dd81187bcd9961323011509c8f644a1c0a3f14ee40d7dd186f807f9edc7c02f6761061bbb6dd91a6c96ec0b9f10edbbd29dc52
|
||||||
|
Output = 02535d86cc7518484a2a238c921b739b1704a50370a2924abf39958c5976e658dc5e87440063112459bddb40308b1c70
|
||||||
|
|
||||||
|
|
||||||
|
Digest = SHA3-512
|
||||||
|
Input = ""
|
||||||
|
Output = A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26
|
||||||
|
|
||||||
|
Digest = SHA3-512
|
||||||
|
Input = A3
|
||||||
|
Count = 200
|
||||||
|
Output = E76DFAD22084A8B1467FCF2FFA58361BEC7628EDF5F3FDC0E4805DC48CAEECA81B7C13C30ADF52A3659584739A2DF46BE589C51CA1A4A8416DF6545A1CE8BA00
|
||||||
|
|
||||||
|
Digest = SHA3-512
|
||||||
|
Input = 664ef2e3a7059daf1c58caf52008c5227e85cdcb83b4c59457f02c508d4f4f69f826bd82c0cffc5cb6a97af6e561c6f96970005285e58f21ef6511d26e709889a7e513c434c90a3cf7448f0caeec7114c747b2a0758a3b4503a7cf0c69873ed31d94dbef2b7b2f168830ef7da3322c3d3e10cafb7c2c33c83bbf4c46a31da90cff3bfd4ccc6ed4b310758491eeba603a76
|
||||||
|
Output = e5825ff1a3c070d5a52fbbe711854a440554295ffb7a7969a17908d10163bfbe8f1d52a676e8a0137b56a11cdf0ffbb456bc899fc727d14bd8882232549d914e
|
||||||
|
|
||||||
|
Digest = SHA3-512
|
||||||
|
Input = 991c4e7402c7da689dd5525af76fcc58fe9cc1451308c0c4600363586ccc83c9ec10a8c9ddaec3d7cfbd206484d09634b9780108440bf27a5fa4a428446b3214fa17084b6eb197c5c59a4e8df1cfc521826c3b1cbf6f4212f6bfb9bc106dfb5568395643de58bffa2774c31e67f5c1e7017f57caadbb1a56cc5b8a5cf9584552e17e7af9542ba13e9c54695e0dc8f24eddb93d5a3678e10c8a80ff4f27b677d40bef5cb5f9b3a659cc4127970cd2c11ebf22d514812dfefdd73600dfc10efba38e93e5bff47736126043e50f8b9b941e4ec3083fb762dbf15c86
|
||||||
|
Output = cd0f2a48e9aa8cc700d3f64efb013f3600ebdbb524930c682d21025eab990eb6d7c52e611f884031fafd9360e5225ab7e4ec24cbe97f3af6dbe4a86a4f068ba7
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = ""
|
||||||
|
Output = 7F9C2BA4E88F827D616045507605853ED73B8093F6EFBC88EB1A6EACFA66EF263CB1EEA988004B93103CFB0AEEFD2A686E01FA4A58E8A3639CA8A1E3F9AE57E235B8CC873C23DC62B8D260169AFA2F75AB916A58D974918835D25E6A435085B2BADFD6DFAAC359A5EFBB7BCC4B59D538DF9A04302E10C8BC1CBF1A0B3A5120EA17CDA7CFAD765F5623474D368CCCA8AF0007CD9F5E4C849F167A580B14AABDEFAEE7EEF47CB0FCA9767BE1FDA69419DFB927E9DF07348B196691ABAEB580B32DEF58538B8D23F87732EA63B02B4FA0F4873360E2841928CD60DD4CEE8CC0D4C922A96188D032675C8AC850933C7AFF1533B94C834ADBB69C6115BAD4692D8619F90B0CDF8A7B9C264029AC185B70B83F2801F2F4B3F70C593EA3AEEB613A7F1B1DE33FD75081F592305F2E4526EDC09631B10958F464D889F31BA010250FDA7F1368EC2967FC84EF2AE9AFF268E0B1700AFFC6820B523A3D917135F2DFF2EE06BFE72B3124721D4A26C04E53A75E30E73A7A9C4A95D91C55D495E9F51DD0B5E9D83C6D5E8CE803AA62B8D654DB53D09B8DCFF273CDFEB573FAD8BCD45578BEC2E770D01EFDE86E721A3F7C6CCE275DABE6E2143F1AF18DA7EFDDC4C7B70B5E345DB93CC936BEA323491CCB38A388F546A9FF00DD4E1300B9B2153D2041D205B443E41B45A653F2A5C4492C1ADD544512DDA2529833462B71A41A45BE97290B6F
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = A3
|
||||||
|
Count = 200
|
||||||
|
Output = 131AB8D2B594946B9C81333F9BB6E0CE75C3B93104FA3469D3917457385DA037CF232EF7164A6D1EB448C8908186AD852D3F85A5CF28DA1AB6FE3438171978467F1C05D58C7EF38C284C41F6C2221A76F12AB1C04082660250802294FB87180213FDEF5B0ECB7DF50CA1F8555BE14D32E10F6EDCDE892C09424B29F597AFC270C904556BFCB47A7D40778D390923642B3CBD0579E60908D5A000C1D08B98EF933F806445BF87F8B009BA9E94F7266122ED7AC24E5E266C42A82FA1BBEFB7B8DB0066E16A85E0493F07DF4809AEC084A593748AC3DDE5A6D7AAE1E8B6E5352B2D71EFBB47D4CAEED5E6D633805D2D323E6FD81B4684B93A2677D45E7421C2C6AEA259B855A698FD7D13477A1FE53E5A4A6197DBEC5CE95F505B520BCD9570C4A8265A7E01F89C0C002C59BFEC6CD4A5C109258953EE5EE70CD577EE217AF21FA70178F0946C9BF6CA8751793479F6B537737E40B6ED28511D8A2D7E73EB75F8DAAC912FF906E0AB955B083BAC45A8E5E9B744C8506F37E9B4E749A184B30F43EB188D855F1B70D71FF3E50C537AC1B0F8974F0FE1A6AD295BA42F6AEC74D123A7ABEDDE6E2C0711CAB36BE5ACB1A5A11A4B1DB08BA6982EFCCD716929A7741CFC63AA4435E0B69A9063E880795C3DC5EF3272E11C497A91ACF699FEFEE206227A44C9FB359FD56AC0A9A75A743CFF6862F17D7259AB075216C0699511643B6439
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = a6fe00064257aa318b621c5eb311d32bb8004c2fa1a969d205d71762cc5d2e633907992629d1b69d9557ff6d5e8deb454ab00f6e497c89a4fea09e257a6fa2074bd818ceb5981b3e3faefd6e720f2d1edd9c5e4a5c51e5009abf636ed5bca53fe159c8287014a1bd904f5c8a7501625f79ac81eb618f478ce21cae6664acffb30572f059e1ad0fc2912264e8f1ca52af26c8bf78e09d75f3dd9fc734afa8770abe0bd78c90cc2ff448105fb16dd2c5b7edd8611a62e537db9331f5023e16d6ec150cc6e706d7c7fcbfff930c7281831fd5c4aff86ece57ed0db882f59a5fe403105d0592ca38a081fed84922873f538ee774f13b8cc09bd0521db4374aec69f4bae6dcb66455822c0b84c91a3474ffac2ad06f0a4423cd2c6a49d4f0d6242d6a1890937b5d9835a5f0ea5b1d01884d22a6c1718e1f60b3ab5e232947c76ef70b344171083c688093b5f1475377e3069863
|
||||||
|
Output = 3109d9472ca436e805c6b3db2251a9bc
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = 49d81708d86cd59dea0ac2c1017a9712d6dffb754dde0b57a9023a39fc5f5b6be276fc176f59f6826610428fac3a0e85fcf71011db061b8fcf2bf085ccd45670effb6dc46f4e3f2ed08e981c5935187fc95b86cf46da675096b1cf9591a67842d6301116be93d8288e4d6b70f1b1db8aa5d203b774a21825665b8170351ee86801da91154570eaf80a1564945af7822df8232fd04ea65593a7f2ab1e9e84cf6ad6c494c9ec2d9d27aaad2b8f7e4f33f12a17b422bc2d4724c13ff8a8b62054d1bfb5c33b9c11183cd8df67694300165ca37637b5a781155f1c070d156339a0242374c6723b6584bffb71c02b935455f8cb086392f5e8e8cc2015956d8f19daeb6aca4476b27108387a2ce0dc5591154d0b94ddc090abe8f4363036b821062baffb7fe550ea7dcd30bfd86c84710081e1c9e450475e123c5ec41f98ff0149bbf6405b5207cad1fb2f313d0f2bcee9be3f6ebe623049640d9234ab644a172ab14ba02633a339b5b9bb38226fda5694f7ec63ebbb8238eb8219ec9c429f4bf0353383a72f2d21702f5e3c513499f04852710f33044512edc47a56bad90885e5713851a7efac694b869fa590076e844ff757d95de581c1b3fa3dd8ccd28cad4f8ae173ee1b28f98ee606dca89063fbef0f262b33053f2c854debdc9cd433ab77abb64f445aa9b981761c4761767f3b71c2646c7b0d873baae50bc9f0
|
||||||
|
Output = c609be05458f7ab33e7b6b54bc6e8999
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = ""
|
||||||
|
Output = 46B9DD2B0BA88D13233B3FEB743EEB243FCD52EA62B81B82B50C27646ED5762FD75DC4DDD8C0F200CB05019D67B592F6FC821C49479AB48640292EACB3B7C4BE141E96616FB13957692CC7EDD0B45AE3DC07223C8E92937BEF84BC0EAB862853349EC75546F58FB7C2775C38462C5010D846C185C15111E595522A6BCD16CF86F3D122109E3B1FDD943B6AEC468A2D621A7C06C6A957C62B54DAFC3BE87567D677231395F6147293B68CEAB7A9E0C58D864E8EFDE4E1B9A46CBE854713672F5CAAAE314ED9083DAB4B099F8E300F01B8650F1F4B1D8FCF3F3CB53FB8E9EB2EA203BDC970F50AE55428A91F7F53AC266B28419C3778A15FD248D339EDE785FB7F5A1AAA96D313EACC890936C173CDCD0FAB882C45755FEB3AED96D477FF96390BF9A66D1368B208E21F7C10D04A3DBD4E360633E5DB4B602601C14CEA737DB3DCF722632CC77851CBDDE2AAF0A33A07B373445DF490CC8FC1E4160FF118378F11F0477DE055A81A9EDA57A4A2CFB0C83929D310912F729EC6CFA36C6AC6A75837143045D791CC85EFF5B21932F23861BCF23A52B5DA67EAF7BAAE0F5FB1369DB78F3AC45F8C4AC5671D85735CDDDB09D2B1E34A1FC066FF4A162CB263D6541274AE2FCC865F618ABE27C124CD8B074CCD516301B91875824D09958F341EF274BDAB0BAE316339894304E35877B0C28A9B1FD166C796B9CC258A064A8F57E27F2A
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = A3
|
||||||
|
Count = 200
|
||||||
|
Output = CD8A920ED141AA0407A22D59288652E9D9F1A7EE0C1E7C1CA699424DA84A904D2D700CAAE7396ECE96604440577DA4F3AA22AEB8857F961C4CD8E06F0AE6610B1048A7F64E1074CD629E85AD7566048EFC4FB500B486A3309A8F26724C0ED628001A1099422468DE726F1061D99EB9E93604D5AA7467D4B1BD6484582A384317D7F47D750B8F5499512BB85A226C4243556E696F6BD072C5AA2D9B69730244B56853D16970AD817E213E470618178001C9FB56C54FEFA5FEE67D2DA524BB3B0B61EF0E9114A92CDBB6CCCB98615CFE76E3510DD88D1CC28FF99287512F24BFAFA1A76877B6F37198E3A641C68A7C42D45FA7ACC10DAE5F3CEFB7B735F12D4E589F7A456E78C0F5E4C4471FFFA5E4FA0514AE974D8C2648513B5DB494CEA847156D277AD0E141C24C7839064CD08851BC2E7CA109FD4E251C35BB0A04FB05B364FF8C4D8B59BC303E25328C09A882E952518E1A8AE0FF265D61C465896973D7490499DC639FB8502B39456791B1B6EC5BCC5D9AC36A6DF622A070D43FED781F5F149F7B62675E7D1A4D6DEC48C1C7164586EAE06A51208C0B791244D307726505C3AD4B26B6822377257AA152037560A739714A3CA79BD605547C9B78DD1F596F2D4F1791BC689A0E9B799A37339C04275733740143EF5D2B58B96A363D4E08076A1A9D7846436E4DCA5728B6F760EEF0CA92BF0BE5615E96959D767197A0BEEB
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = dc5a100fa16df1583c79722a0d72833d3bf22c109b8889dbd35213c6bfce205813edae3242695cfd9f59b9a1c203c1b72ef1a5423147cb990b5316a85266675894e2644c3f9578cebe451a09e58c53788fe77a9e850943f8a275f830354b0593a762bac55e984db3e0661eca3cb83f67a6fb348e6177f7dee2df40c4322602f094953905681be3954fe44c4c902c8f6bba565a788b38f13411ba76ce0f9f6756a2a2687424c5435a51e62df7a8934b6e141f74c6ccf539e3782d22b5955d3baf1ab2cf7b5c3f74ec2f9447344e937957fd7f0bdfec56d5d25f61cde18c0986e244ecf780d6307e313117256948d4230ebb9ea62bb302cfe80d7dfebabc4a51d7687967ed5b416a139e974c005fff507a96
|
||||||
|
Output = 2bac5716803a9cda8f9e84365ab0a681327b5ba34fdedfb1c12e6e807f45284b
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = 16caf60da14b4fa9174a6d40c23cff93ed8fc9279990f749718db1500036ef2222498ffab86fa568a0611299e54e58d83281ac558d3f4d2541ee158b1c7d4d76dbffc64ae39925e3329f7fd894fa26fc1acdc22bc858a3438e1c55707a3f75ad2b33c48789937a24b34ddd85390611088cba3231b2a3a0a93e5d9a8780470fcff92cb03811234a330db353283b3bc3036f9125efb3eaed613bfa0c59975cc2e52c33b3e6e5123e1626190a4a0261e1f5ad9bc2ee34f331736b3bd26d274536f5ae90f5186c27fdd7e8c72972f64016e72d1d32b59b8715e5b867154b99cb140a668b9d560e2c307e3904d9297f9f07dfd7629ccc526e41c109c8fc7c53b604293c6cd42933e77e11031a42f605485fe893b129bcbf705c0f45a4b087bfcead5c187ac1174322909a2d4f8b61f001c4074951000c4c550ed5564458f444dab8aae2fe8daaa6a30d209fecddf2a893df46e18b4b4460e4011d23f01d4c49a4cc1c82405f6ac5339eac41385f3295c657ac43a72fed62e6daee94ef271638f292b8e18860de0699eb45fb7d3aa81f61d44158edd68ebc244451918b
|
||||||
|
Output = 21a48efd949c3f785179a0e340756a23f77d29a7625229a71a05731c7fbd5aa9
|
||||||
|
|
||||||
|
# Following tests are pairs of *last* "VariableOut" vectors from
|
||||||
|
# http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html#test-vectors
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = c60a221c975e14bf835827c1103a2906
|
||||||
|
Output = 0db7f7196eee8dd6994a16ded19cb09f05f89ccd2464333df2c017c6ca041fa0d54a4832a74ce86ce9b41d8e523e66ce6ef9df7c20aa70e0ac00f54eb072a472ef46cf2a933df0d5f9fafab6388a206f6bd1df50b0836500c758c557c8ac965733fdaaa59f5ed661a1bda61e2952886a60f9568157e3d72e49b6e061fc08f3f1caf159e8eff77ea5221565d2
|
||||||
|
|
||||||
|
Digest = SHAKE128
|
||||||
|
Input = 0a13ad2c7a239b4ba73ea6592ae84ea9
|
||||||
|
Output = 5feaf99c15f48851943ff9baa6e5055d8377f0dd347aa4dbece51ad3a6d9ce0c01aee9fe2260b80a4673a909b532adcdd1e421c32d6460535b5fe392a58d2634979a5a104d6c470aa3306c400b061db91c463b2848297bca2bc26d1864ba49d7ff949ebca50fbf79a5e63716dc82b600bd52ca7437ed774d169f6bf02e46487956fba2230f34cd2a0485484d
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = 6ae23f058f0f2264a18cd609acc26dd4dbc00f5c3ee9e13ecaea2bb5a2f0bb6b
|
||||||
|
Output = b9b92544fb25cfe4ec6fe437d8da2bbe00f7bdaface3de97b8775a44d753c3adca3f7c6f183cc8647e229070439aa9539ae1f8f13470c9d3527fffdeef6c94f9f0520ff0c1ba8b16e16014e1af43ac6d94cb7929188cce9d7b02f81a2746f52ba16988e5f6d93298d778dfe05ea0ef256ae3728643ce3e29c794a0370e9ca6a8bf3e7a41e86770676ac106f7ae79e67027ce7b7b38efe27d253a52b5cb54d6eb4367a87736ed48cb45ef27f42683da140ed3295dfc575d3ea38cfc2a3697cc92864305407369b4abac054e497378dd9fd0c4b352ea3185ce1178b3dc1599df69db29259d4735320c8e7d33e8226620c9a1d22761f1d35bdff79a
|
||||||
|
|
||||||
|
Digest = SHAKE256
|
||||||
|
Input = 8d8001e2c096f1b88e7c9224a086efd4797fbf74a8033a2d422a2b6b8f6747e4
|
||||||
|
Output = 2e975f6a8a14f0704d51b13667d8195c219f71e6345696c49fa4b9d08e9225d3d39393425152c97e71dd24601c11abcfa0f12f53c680bd3ae757b8134a9c10d429615869217fdd5885c4db174985703a6d6de94a667eac3023443a8337ae1bc601b76d7d38ec3c34463105f0d3949d78e562a039e4469548b609395de5a4fd43c46ca9fd6ee29ada5efc07d84d553249450dab4a49c483ded250c9338f85cd937ae66bb436f3b4026e859fda1ca571432f3bfc09e7c03ca4d183b741111ca0483d0edabc03feb23b17ee48e844ba2408d9dcfd0139d2e8c7310125aee801c61ab7900d1efc47c078281766f361c5e6111346235e1dc38325666c
|
||||||
|
|
||||||
|
|
||||||
|
Digest = CSHAKE128
|
||||||
|
Input = "abc"
|
||||||
|
Output = 5881092dd818bf5cf8a3ddb793fbcba74097d5c526a6d35f97b83351940f2cc8
|
||||||
|
|
||||||
|
Digest = CSHAKE256
|
||||||
|
Input = "abc"
|
||||||
|
Output = 483366601360a8771c6863080cc4114d8db44530f8f1e1ee4f94ea37e78b5739d5a15bef186a5386c75744c0527e1faa9f8726e462a12a4feb06bd8801e751e4
|
||||||
|
|
||||||
|
Title = Case insensitive digest tests
|
||||||
|
|
||||||
|
Digest = Sha3-256
|
||||||
|
Input = ""
|
||||||
|
Output = A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A
|
||||||
|
|
||||||
|
Digest = shA512
|
||||||
|
Input = "abc"
|
||||||
|
Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
|
||||||
|
|
|
@ -21,6 +21,10 @@ set(SCOSSL_SOURCES
|
||||||
./src/ciphers/p_scossl_aes.c
|
./src/ciphers/p_scossl_aes.c
|
||||||
./src/ciphers/p_scossl_aes_aead.c
|
./src/ciphers/p_scossl_aes_aead.c
|
||||||
./src/ciphers/p_scossl_aes_xts.c
|
./src/ciphers/p_scossl_aes_xts.c
|
||||||
|
./src/digests/p_scossl_digest_common.c
|
||||||
|
./src/digests/p_scossl_digest_generic.c
|
||||||
|
./src/digests/p_scossl_shake.c
|
||||||
|
./src/digests/p_scossl_cshake.c
|
||||||
./src/kdf/p_scossl_hkdf.c
|
./src/kdf/p_scossl_hkdf.c
|
||||||
./src/kdf/p_scossl_kbkdf.c
|
./src/kdf/p_scossl_kbkdf.c
|
||||||
./src/kdf/p_scossl_srtpkdf.c
|
./src/kdf/p_scossl_srtpkdf.c
|
||||||
|
@ -37,7 +41,6 @@ set(SCOSSL_SOURCES
|
||||||
./src/mac/p_scossl_kmac.c
|
./src/mac/p_scossl_kmac.c
|
||||||
./src/signature/p_scossl_ecdsa_signature.c
|
./src/signature/p_scossl_ecdsa_signature.c
|
||||||
./src/signature/p_scossl_rsa_signature.c
|
./src/signature/p_scossl_rsa_signature.c
|
||||||
./src/p_scossl_digests.c
|
|
||||||
./src/p_scossl_ecc.c
|
./src/p_scossl_ecc.c
|
||||||
./src/p_scossl_rand.c
|
./src/p_scossl_rand.c
|
||||||
./src/p_scossl_rsa.c
|
./src/p_scossl_rsa.c
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Digest parameters
|
||||||
|
//
|
||||||
|
|
||||||
|
#define SCOSSL_DIGEST_PARAM_FUNCTION_NAME_STRING "function-name-string"
|
||||||
|
#define SCOSSL_DIGEST_PARAM_CUSTOMIZATION_STRING "customization-string"
|
||||||
|
|
||||||
//
|
//
|
||||||
// KDF parameters
|
// KDF parameters
|
||||||
//
|
//
|
||||||
|
|
|
@ -0,0 +1,423 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <openssl/core_names.h>
|
||||||
|
#include <openssl/proverr.h>
|
||||||
|
|
||||||
|
#include "scossl_provider.h"
|
||||||
|
#include "p_scossl_digest_common.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SCOSSL_XOF_STATE_INIT = 0,
|
||||||
|
SCOSSL_XOF_STATE_UPDATE,
|
||||||
|
SCOSSL_XOF_STATE_FINAL,
|
||||||
|
SCOSSL_XOF_STATE_SQUEEZE,
|
||||||
|
} SCOSSL_XOF_STATE;
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
SYMCRYPT_CSHAKE128_STATE cshake128State;
|
||||||
|
SYMCRYPT_CSHAKE256_STATE cshake256State;
|
||||||
|
} SCOSSL_CSHAKE_STATE;
|
||||||
|
|
||||||
|
typedef VOID (SYMCRYPT_CALL * PSYMCRYPT_CSHAKE_DIGEST) (
|
||||||
|
PCBYTE pbFunctionNameString, SIZE_T cbFunctionNameString,
|
||||||
|
PCBYTE pbCustomizationString, SIZE_T cbCustomizationString,
|
||||||
|
PCBYTE pbData, SIZE_T cbData,
|
||||||
|
PBYTE pbResult, SIZE_T cbResult);
|
||||||
|
|
||||||
|
typedef VOID (SYMCRYPT_CALL * PSYMCRYPT_CSHAKE_INIT) (
|
||||||
|
SCOSSL_CSHAKE_STATE *pState,
|
||||||
|
PCBYTE pbFunctionNameString, SIZE_T cbFunctionNameString,
|
||||||
|
PCBYTE pbCustomizationString, SIZE_T cbCustomizationString);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PSYMCRYPT_CSHAKE_DIGEST digestFunc;
|
||||||
|
PSYMCRYPT_CSHAKE_INIT initFunc;
|
||||||
|
PSYMCRYPT_HASH_APPEND_FUNC appendFunc;
|
||||||
|
PSYMCRYPT_HASH_EXTRACT extractFunc;
|
||||||
|
PSYMCRYPT_HASH_STATE_COPY_FUNC stateCopyFunc;
|
||||||
|
|
||||||
|
SIZE_T blockSize;
|
||||||
|
SIZE_T resultSize;
|
||||||
|
} SCOSSL_CSHAKE_HASH;
|
||||||
|
|
||||||
|
static const SCOSSL_CSHAKE_HASH SymCryptCShake128Algorithm = {
|
||||||
|
SymCryptCShake128,
|
||||||
|
(PSYMCRYPT_CSHAKE_INIT)SymCryptCShake128Init,
|
||||||
|
(PSYMCRYPT_HASH_APPEND_FUNC)SymCryptCShake128Append,
|
||||||
|
(PSYMCRYPT_HASH_EXTRACT)SymCryptCShake128Extract,
|
||||||
|
(PSYMCRYPT_HASH_STATE_COPY_FUNC)SymCryptCShake128StateCopy,
|
||||||
|
SYMCRYPT_CSHAKE128_INPUT_BLOCK_SIZE,
|
||||||
|
SYMCRYPT_CSHAKE128_RESULT_SIZE};
|
||||||
|
|
||||||
|
static const SCOSSL_CSHAKE_HASH SymCryptCShake256Algorithm = {
|
||||||
|
SymCryptCShake256,
|
||||||
|
(PSYMCRYPT_CSHAKE_INIT)SymCryptCShake256Init,
|
||||||
|
(PSYMCRYPT_HASH_APPEND_FUNC)SymCryptCShake256Append,
|
||||||
|
(PSYMCRYPT_HASH_EXTRACT)SymCryptCShake256Extract,
|
||||||
|
(PSYMCRYPT_HASH_STATE_COPY_FUNC)SymCryptCShake256StateCopy,
|
||||||
|
SYMCRYPT_CSHAKE256_INPUT_BLOCK_SIZE,
|
||||||
|
SYMCRYPT_CSHAKE256_RESULT_SIZE};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const SCOSSL_CSHAKE_HASH *pHash;
|
||||||
|
SCOSSL_CSHAKE_STATE state;
|
||||||
|
SCOSSL_XOF_STATE xofState;
|
||||||
|
|
||||||
|
PBYTE pbFunctionNameString;
|
||||||
|
SIZE_T cbFunctionNameString;
|
||||||
|
PBYTE pbCustomizationString;
|
||||||
|
SIZE_T cbCustomizationString;
|
||||||
|
|
||||||
|
SIZE_T xofLen;
|
||||||
|
} SCOSSL_CSHAKE_CTX;
|
||||||
|
|
||||||
|
static const OSSL_PARAM p_scossl_cshake_settable_ctx_param_types[] = {
|
||||||
|
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_XOFLEN, NULL),
|
||||||
|
OSSL_PARAM_octet_string(SCOSSL_DIGEST_PARAM_FUNCTION_NAME_STRING, NULL, 0),
|
||||||
|
OSSL_PARAM_octet_string(SCOSSL_DIGEST_PARAM_CUSTOMIZATION_STRING, NULL, 0),
|
||||||
|
OSSL_PARAM_END};
|
||||||
|
|
||||||
|
static const OSSL_PARAM p_scossl_cshake_settable_ctx_param_types_initialized[] = {
|
||||||
|
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_XOFLEN, NULL),
|
||||||
|
OSSL_PARAM_END};
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_set_ctx_params(_Inout_ SCOSSL_CSHAKE_CTX *ctx, _In_ const OSSL_PARAM params[]);
|
||||||
|
|
||||||
|
static SCOSSL_CSHAKE_CTX *p_scossl_cshake_newctx(const SCOSSL_CSHAKE_HASH *pHash)
|
||||||
|
{
|
||||||
|
SCOSSL_COMMON_ALIGNED_ALLOC(ctx, OPENSSL_zalloc, SCOSSL_CSHAKE_CTX);
|
||||||
|
|
||||||
|
if (ctx != NULL)
|
||||||
|
{
|
||||||
|
ctx->pHash = pHash;
|
||||||
|
ctx->xofLen = pHash->resultSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_CSHAKE_CTX *p_scossl_cshake_128_newctx()
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_newctx(&SymCryptCShake128Algorithm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_CSHAKE_CTX *p_scossl_cshake_256_newctx()
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_newctx(&SymCryptCShake256Algorithm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void p_scossl_cshake_freectx(_Inout_ SCOSSL_CSHAKE_CTX *ctx)
|
||||||
|
{
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OPENSSL_free(ctx->pbFunctionNameString);
|
||||||
|
OPENSSL_free(ctx->pbCustomizationString);
|
||||||
|
SCOSSL_COMMON_ALIGNED_FREE(ctx, OPENSSL_clear_free, SCOSSL_CSHAKE_CTX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_CSHAKE_CTX *p_scossl_cshake_dupctx(_In_ SCOSSL_CSHAKE_CTX *ctx)
|
||||||
|
{
|
||||||
|
SCOSSL_STATUS status = SCOSSL_FAILURE;
|
||||||
|
|
||||||
|
SCOSSL_COMMON_ALIGNED_ALLOC(copyCtx, OPENSSL_zalloc, SCOSSL_CSHAKE_CTX);
|
||||||
|
|
||||||
|
if (ctx != NULL)
|
||||||
|
{
|
||||||
|
if (ctx->pbFunctionNameString != NULL)
|
||||||
|
{
|
||||||
|
copyCtx->pbFunctionNameString = OPENSSL_memdup(ctx->pbFunctionNameString, ctx->cbFunctionNameString);
|
||||||
|
if (copyCtx->pbFunctionNameString == NULL)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copyCtx->pbFunctionNameString = NULL;
|
||||||
|
}
|
||||||
|
copyCtx->cbFunctionNameString = ctx->cbFunctionNameString;
|
||||||
|
|
||||||
|
if (ctx->pbCustomizationString != NULL)
|
||||||
|
{
|
||||||
|
copyCtx->pbCustomizationString = OPENSSL_memdup(ctx->pbCustomizationString, ctx->cbCustomizationString);
|
||||||
|
if (copyCtx->pbCustomizationString == NULL)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copyCtx->pbCustomizationString = NULL;
|
||||||
|
}
|
||||||
|
copyCtx->cbCustomizationString = ctx->cbCustomizationString;
|
||||||
|
|
||||||
|
ctx->pHash->stateCopyFunc(&ctx->state, ©Ctx->state);
|
||||||
|
|
||||||
|
copyCtx->pHash = ctx->pHash;
|
||||||
|
copyCtx->xofState = ctx->xofState;
|
||||||
|
copyCtx->xofLen = ctx->xofLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = SCOSSL_SUCCESS;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (status != SCOSSL_SUCCESS)
|
||||||
|
{
|
||||||
|
p_scossl_cshake_freectx(copyCtx);
|
||||||
|
copyCtx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copyCtx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_init(_Inout_ SCOSSL_CSHAKE_CTX *ctx, _In_ const OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
ctx->xofState = SCOSSL_XOF_STATE_INIT;
|
||||||
|
|
||||||
|
return p_scossl_cshake_set_ctx_params(ctx, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_update(_Inout_ SCOSSL_CSHAKE_CTX *ctx,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl)
|
||||||
|
{
|
||||||
|
if (ctx->xofState == SCOSSL_XOF_STATE_FINAL ||
|
||||||
|
ctx->xofState == SCOSSL_XOF_STATE_SQUEEZE)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay init until first update call, in case function name or customization strings
|
||||||
|
// are set by parameter after the init call.
|
||||||
|
if (ctx->xofState == SCOSSL_XOF_STATE_INIT)
|
||||||
|
{
|
||||||
|
ctx->pHash->initFunc(
|
||||||
|
&ctx->state,
|
||||||
|
ctx->pbFunctionNameString, ctx->cbFunctionNameString,
|
||||||
|
ctx->pbCustomizationString, ctx->cbCustomizationString);
|
||||||
|
|
||||||
|
ctx->xofState = SCOSSL_XOF_STATE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->pHash->appendFunc(&ctx->state, in, inl);
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_extract(_In_ SCOSSL_CSHAKE_CTX *ctx, BOOL wipeState,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
if (outlen < ctx->xofLen)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->xofState == SCOSSL_XOF_STATE_FINAL)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay init until first update call, in case function name or customization strings
|
||||||
|
// are set by parameter after the init call.
|
||||||
|
if (ctx->xofState == SCOSSL_XOF_STATE_INIT)
|
||||||
|
{
|
||||||
|
ctx->pHash->initFunc(
|
||||||
|
&ctx->state,
|
||||||
|
ctx->pbFunctionNameString, ctx->cbFunctionNameString,
|
||||||
|
ctx->pbCustomizationString, ctx->cbCustomizationString);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->pHash->extractFunc(&ctx->state, out, ctx->xofLen, wipeState);
|
||||||
|
*outl = ctx->xofLen;
|
||||||
|
|
||||||
|
if (wipeState)
|
||||||
|
{
|
||||||
|
ctx->xofState = SCOSSL_XOF_STATE_FINAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx->xofState = SCOSSL_XOF_STATE_SQUEEZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_final(_In_ SCOSSL_CSHAKE_CTX *ctx,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_extract(ctx, TRUE, out, outl, outlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OSSL_FUNC_DIGEST_SQUEEZE
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_squeeze(_In_ SCOSSL_CSHAKE_CTX *ctx,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_extract(ctx, FALSE, out, outl, outlen);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_digest(_In_ const SCOSSL_CSHAKE_HASH *pHash,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
SIZE_T cbResult = pHash->resultSize;
|
||||||
|
|
||||||
|
if (outlen < cbResult)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pHash->digestFunc(
|
||||||
|
NULL, 0,
|
||||||
|
NULL, 0,
|
||||||
|
in, inl,
|
||||||
|
out, cbResult);
|
||||||
|
|
||||||
|
*outl = cbResult;
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_128_digest(ossl_unused void *prov_ctx,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_digest(&SymCryptCShake128Algorithm, in, inl, out, outl, outlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_256_digest(ossl_unused void *prov_ctx,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
return p_scossl_cshake_digest(&SymCryptCShake256Algorithm, in, inl, out, outl, outlen);
|
||||||
|
}
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_128_get_params(_Inout_ OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
return p_scossl_digest_get_params(params,
|
||||||
|
SymCryptCShake128Algorithm.resultSize,
|
||||||
|
SymCryptCShake128Algorithm.blockSize,
|
||||||
|
SCOSSL_DIGEST_FLAG_XOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_256_get_params(_Inout_ OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
return p_scossl_digest_get_params(params,
|
||||||
|
SymCryptCShake256Algorithm.resultSize,
|
||||||
|
SymCryptCShake256Algorithm.blockSize,
|
||||||
|
SCOSSL_DIGEST_FLAG_XOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_cshake_set_ctx_params(_Inout_ SCOSSL_CSHAKE_CTX *ctx, _In_ const OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
const OSSL_PARAM *p;
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate_const(params, SCOSSL_DIGEST_PARAM_FUNCTION_NAME_STRING)) != NULL)
|
||||||
|
{
|
||||||
|
if (ctx->xofState != SCOSSL_XOF_STATE_INIT)
|
||||||
|
{
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_free(ctx->pbFunctionNameString);
|
||||||
|
ctx->pbFunctionNameString = NULL;
|
||||||
|
|
||||||
|
if (p->data != NULL &&
|
||||||
|
!OSSL_PARAM_get_octet_string(p, (void **)&ctx->pbFunctionNameString, 0, &ctx->cbFunctionNameString))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate_const(params, SCOSSL_DIGEST_PARAM_CUSTOMIZATION_STRING)) != NULL)
|
||||||
|
{
|
||||||
|
if (ctx->xofState != SCOSSL_XOF_STATE_INIT)
|
||||||
|
{
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_free(ctx->pbCustomizationString);
|
||||||
|
ctx->pbCustomizationString = NULL;
|
||||||
|
|
||||||
|
if (p->data != NULL &&
|
||||||
|
!OSSL_PARAM_get_octet_string(p, (void **)&ctx->pbCustomizationString, 0, &ctx->cbCustomizationString))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN)) != NULL &&
|
||||||
|
!OSSL_PARAM_get_size_t(p, &ctx->xofLen))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const OSSL_PARAM *p_scossl_cshake_settable_ctx_params(_In_ SCOSSL_CSHAKE_CTX *ctx, ossl_unused void *provctx)
|
||||||
|
{
|
||||||
|
return ctx->xofState == SCOSSL_XOF_STATE_INIT ? p_scossl_cshake_settable_ctx_param_types : p_scossl_cshake_settable_ctx_param_types_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OSSL_FUNC_DIGEST_SQUEEZE
|
||||||
|
#define SCOSSL_DIGEST_CSHAKE_SQUEEZE \
|
||||||
|
{OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))p_scossl_cshake_squeeze},
|
||||||
|
#else
|
||||||
|
#define SCOSSL_DIGEST_CSHAKE_SQUEEZE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const OSSL_DISPATCH p_scossl_cshake_128_functions[] = {
|
||||||
|
{OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void)) p_scossl_cshake_128_newctx},
|
||||||
|
{OSSL_FUNC_DIGEST_FREECTX, (void (*)(void)) p_scossl_cshake_freectx},
|
||||||
|
{OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void)) p_scossl_cshake_dupctx},
|
||||||
|
{OSSL_FUNC_DIGEST_INIT, (void (*)(void)) p_scossl_cshake_init},
|
||||||
|
{OSSL_FUNC_DIGEST_UPDATE, (void (*)(void)) p_scossl_cshake_update},
|
||||||
|
{OSSL_FUNC_DIGEST_FINAL, (void (*)(void)) p_scossl_cshake_final},
|
||||||
|
{OSSL_FUNC_DIGEST_DIGEST, (void (*)(void)) p_scossl_cshake_128_digest},
|
||||||
|
{OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void)) p_scossl_cshake_128_get_params},
|
||||||
|
{OSSL_FUNC_DIGEST_GETTABLE_PARAMS, (void (*)(void)) p_scossl_digest_gettable_params},
|
||||||
|
{OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void)) p_scossl_cshake_set_ctx_params},
|
||||||
|
{OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, (void (*)(void)) p_scossl_cshake_settable_ctx_params},
|
||||||
|
#ifdef OSSL_FUNC_DIGEST_SQUEEZE
|
||||||
|
{OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))p_scossl_cshake_squeeze},
|
||||||
|
#endif
|
||||||
|
{0, NULL}};
|
||||||
|
|
||||||
|
const OSSL_DISPATCH p_scossl_cshake_256_functions[] = {
|
||||||
|
{OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void)) p_scossl_cshake_256_newctx},
|
||||||
|
{OSSL_FUNC_DIGEST_FREECTX, (void (*)(void)) p_scossl_cshake_freectx},
|
||||||
|
{OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void)) p_scossl_cshake_dupctx},
|
||||||
|
{OSSL_FUNC_DIGEST_INIT, (void (*)(void)) p_scossl_cshake_init},
|
||||||
|
{OSSL_FUNC_DIGEST_UPDATE, (void (*)(void)) p_scossl_cshake_update},
|
||||||
|
{OSSL_FUNC_DIGEST_FINAL, (void (*)(void)) p_scossl_cshake_final},
|
||||||
|
{OSSL_FUNC_DIGEST_DIGEST, (void (*)(void)) p_scossl_cshake_256_digest},
|
||||||
|
{OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void)) p_scossl_cshake_256_get_params},
|
||||||
|
{OSSL_FUNC_DIGEST_GETTABLE_PARAMS, (void (*)(void)) p_scossl_digest_gettable_params},
|
||||||
|
{OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void)) p_scossl_cshake_set_ctx_params},
|
||||||
|
{OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, (void (*)(void)) p_scossl_cshake_settable_ctx_params},
|
||||||
|
#ifdef OSSL_FUNC_DIGEST_SQUEEZE
|
||||||
|
{OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))p_scossl_cshake_squeeze},
|
||||||
|
#endif
|
||||||
|
{0, NULL}};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,126 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <openssl/core_dispatch.h>
|
||||||
|
#include <openssl/core_names.h>
|
||||||
|
#include <openssl/proverr.h>
|
||||||
|
|
||||||
|
#include "digests/p_scossl_digest_common.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const OSSL_PARAM p_scossl_digest_gettable_param_types[] = {
|
||||||
|
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, NULL),
|
||||||
|
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_SIZE, NULL),
|
||||||
|
OSSL_PARAM_int(OSSL_DIGEST_PARAM_XOF, NULL),
|
||||||
|
OSSL_PARAM_int(OSSL_DIGEST_PARAM_ALGID_ABSENT, NULL),
|
||||||
|
OSSL_PARAM_END};
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
void p_scossl_digest_freectx(SCOSSL_DIGEST_CTX *ctx)
|
||||||
|
{
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ctx->pState != NULL)
|
||||||
|
{
|
||||||
|
SCOSSL_COMMON_ALIGNED_FREE_EX(ctx->pState, OPENSSL_clear_free, SymCryptHashStateSize(ctx->pHash));
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENSSL_free(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
SCOSSL_DIGEST_CTX *p_scossl_digest_dupctx(SCOSSL_DIGEST_CTX *ctx)
|
||||||
|
{
|
||||||
|
SCOSSL_DIGEST_CTX *copyCtx = OPENSSL_malloc(sizeof(SCOSSL_DIGEST_CTX));
|
||||||
|
|
||||||
|
if (copyCtx != NULL)
|
||||||
|
{
|
||||||
|
SCOSSL_COMMON_ALIGNED_ALLOC_EX(pStateTmp, OPENSSL_malloc, PVOID, SymCryptHashStateSize(ctx->pHash));
|
||||||
|
if (pStateTmp == NULL)
|
||||||
|
{
|
||||||
|
OPENSSL_free(copyCtx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->pHash->stateCopyFunc(ctx->pState, pStateTmp);
|
||||||
|
copyCtx->pState = pStateTmp;
|
||||||
|
|
||||||
|
copyCtx->pHash = ctx->pHash;
|
||||||
|
copyCtx->xofLen = ctx->xofLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copyCtx;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
SCOSSL_STATUS p_scossl_digest_get_params(OSSL_PARAM params[], size_t size, size_t blocksize, UINT32 flags)
|
||||||
|
{
|
||||||
|
OSSL_PARAM *p;
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE)) != NULL &&
|
||||||
|
!OSSL_PARAM_set_size_t(p, size))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE)) != NULL &&
|
||||||
|
!OSSL_PARAM_set_size_t(p, blocksize))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_XOF)) != NULL &&
|
||||||
|
!OSSL_PARAM_set_int(p, (flags & SCOSSL_DIGEST_FLAG_XOF) != 0))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_ALGID_ABSENT)) != NULL &&
|
||||||
|
!OSSL_PARAM_set_int(p, (flags & SCOSSL_DIGEST_FLAG_ALGID_ABSENT) != 0))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
const OSSL_PARAM *p_scossl_digest_gettable_params(ossl_unused void *ctx, ossl_unused void *provctx)
|
||||||
|
{
|
||||||
|
return p_scossl_digest_gettable_param_types;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
SCOSSL_STATUS p_scossl_digest_update(SCOSSL_DIGEST_CTX *ctx,
|
||||||
|
const unsigned char *in, size_t inl)
|
||||||
|
{
|
||||||
|
SymCryptHashAppend(ctx->pHash, ctx->pState, in, inl);
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
SCOSSL_STATUS p_scossl_digest_digest(PCSYMCRYPT_HASH pHash,
|
||||||
|
const unsigned char *in, size_t inl,
|
||||||
|
unsigned char *out, size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
SIZE_T cbResult = SymCryptHashResultSize(pHash);
|
||||||
|
|
||||||
|
if (outlen < cbResult)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SymCryptHash(pHash, in, inl, out, cbResult);
|
||||||
|
*outl = cbResult;
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "scossl_helpers.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SCOSSL_DIGEST_FLAG_XOF 0x1
|
||||||
|
#define SCOSSL_DIGEST_FLAG_ALGID_ABSENT 0x2
|
||||||
|
|
||||||
|
typedef VOID (SYMCRYPT_CALL * PSYMCRYPT_HASH_EXTRACT) (PVOID pState, PBYTE pbResult, SIZE_T cbResult, BOOLEAN bWipe);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PCSYMCRYPT_HASH pHash;
|
||||||
|
PVOID pState;
|
||||||
|
|
||||||
|
SIZE_T xofLen;
|
||||||
|
} SCOSSL_DIGEST_CTX;
|
||||||
|
|
||||||
|
SCOSSL_DIGEST_CTX *p_scossl_digest_dupctx(_In_ SCOSSL_DIGEST_CTX *ctx);
|
||||||
|
void p_scossl_digest_freectx(_Inout_ SCOSSL_DIGEST_CTX *ctx);
|
||||||
|
|
||||||
|
SCOSSL_STATUS p_scossl_digest_update(_Inout_ SCOSSL_DIGEST_CTX *ctx,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl);
|
||||||
|
SCOSSL_STATUS p_scossl_digest_digest(_In_ PCSYMCRYPT_HASH pHash,
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen);
|
||||||
|
|
||||||
|
SCOSSL_STATUS p_scossl_digest_get_params(_Inout_ OSSL_PARAM params[], size_t size, size_t blocksize, UINT32 flags);
|
||||||
|
const OSSL_PARAM *p_scossl_digest_gettable_params(ossl_unused void *ctx, ossl_unused void *provctx);
|
||||||
|
|
||||||
|
#define SCOSSL_DIGEST_FUNCTIONS_COMMON(alg, dispatch_name, flags) \
|
||||||
|
static SCOSSL_DIGEST_CTX *p_scossl_##dispatch_name##_newctx(ossl_unused void *prov_ctx) \
|
||||||
|
{ \
|
||||||
|
SCOSSL_DIGEST_CTX *ctx = OPENSSL_malloc(sizeof(SCOSSL_DIGEST_CTX)); \
|
||||||
|
\
|
||||||
|
if (ctx != NULL) \
|
||||||
|
{ \
|
||||||
|
ctx->pHash = SymCrypt##alg##Algorithm; \
|
||||||
|
\
|
||||||
|
SCOSSL_COMMON_ALIGNED_ALLOC_EX( \
|
||||||
|
pStateTmp, \
|
||||||
|
OPENSSL_malloc, \
|
||||||
|
PVOID, \
|
||||||
|
SymCryptHashStateSize(ctx->pHash)); \
|
||||||
|
if (pStateTmp == NULL) \
|
||||||
|
{ \
|
||||||
|
OPENSSL_free(ctx); \
|
||||||
|
return NULL; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
ctx->pState = pStateTmp; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
return ctx; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SCOSSL_STATUS p_scossl_##dispatch_name##_digest( \
|
||||||
|
ossl_unused void *prov_ctx, \
|
||||||
|
_In_reads_bytes_(inl) const unsigned char *in, size_t inl, \
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen) \
|
||||||
|
{ \
|
||||||
|
return p_scossl_digest_digest(SymCrypt##alg##Algorithm, in, inl, out, outl, outlen); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SCOSSL_STATUS p_scossl_##dispatch_name##_get_params(_Inout_ OSSL_PARAM params[]) \
|
||||||
|
{ \
|
||||||
|
return p_scossl_digest_get_params( \
|
||||||
|
params, \
|
||||||
|
SymCryptHashResultSize(SymCrypt##alg##Algorithm), \
|
||||||
|
SymCryptHashInputBlockSize(SymCrypt##alg##Algorithm), \
|
||||||
|
flags); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
const OSSL_DISPATCH p_scossl_##dispatch_name##_functions[] = { \
|
||||||
|
{OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))p_scossl_##dispatch_name##_newctx}, \
|
||||||
|
{OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))p_scossl_digest_freectx}, \
|
||||||
|
{OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))p_scossl_digest_dupctx}, \
|
||||||
|
{OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void))p_scossl_##dispatch_name##_get_params}, \
|
||||||
|
{OSSL_FUNC_DIGEST_GETTABLE_PARAMS, (void (*)(void))p_scossl_digest_gettable_params}, \
|
||||||
|
{OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))p_scossl_digest_update}, \
|
||||||
|
{OSSL_FUNC_DIGEST_DIGEST, (void (*)(void))p_scossl_##dispatch_name##_digest},
|
||||||
|
|
||||||
|
#define SCOSSL_DIGEST_FUNCTIONS_END \
|
||||||
|
{0, NULL}};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,58 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <openssl/proverr.h>
|
||||||
|
|
||||||
|
#include "digests/p_scossl_digest_common.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_digest_generic_init(_Inout_ SCOSSL_DIGEST_CTX *ctx, ossl_unused const OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
SymCryptHashInit(ctx->pHash, ctx->pState);
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_digest_generic_final(_In_ SCOSSL_DIGEST_CTX *ctx,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
SIZE_T cbResult = SymCryptHashResultSize(ctx->pHash);
|
||||||
|
|
||||||
|
if (outlen < cbResult)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SymCryptHashResult(ctx->pHash, ctx->pState, out, cbResult);
|
||||||
|
*outl = cbResult;
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define IMPLEMENT_SCOSSL_DIGEST_GENERIC(alg, dispatch_name, flags) \
|
||||||
|
SCOSSL_DIGEST_FUNCTIONS_COMMON(alg, dispatch_name, flags) \
|
||||||
|
{OSSL_FUNC_DIGEST_INIT, (void (*)(void))p_scossl_digest_generic_init}, \
|
||||||
|
{OSSL_FUNC_DIGEST_FINAL, (void (*)(void))p_scossl_digest_generic_final}, \
|
||||||
|
SCOSSL_DIGEST_FUNCTIONS_END
|
||||||
|
|
||||||
|
// MD5 and SHA1, supported for compatability
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Md5, md5, 0)
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha1, sha1, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
|
||||||
|
// SHA2
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha256, sha256, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha384, sha384, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha512, sha512, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
|
||||||
|
//SHA3
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha3_256, sha3_256, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha3_384, sha3_384, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha3_512, sha3_512, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,103 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <openssl/core_names.h>
|
||||||
|
#include <openssl/proverr.h>
|
||||||
|
|
||||||
|
#include "digests/p_scossl_digest_common.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const OSSL_PARAM p_scossl_shake_settable_ctx_param_types[] = {
|
||||||
|
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_XOFLEN, NULL),
|
||||||
|
OSSL_PARAM_END};
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_shake_set_ctx_params(_Inout_ SCOSSL_DIGEST_CTX *ctx, _In_ const OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
const OSSL_PARAM *p;
|
||||||
|
|
||||||
|
if ((p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN)) != NULL &&
|
||||||
|
!OSSL_PARAM_get_size_t(p, &ctx->xofLen))
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const OSSL_PARAM *p_scossl_shake_settable_ctx_params(ossl_unused void *ctx, ossl_unused void *provctx)
|
||||||
|
{
|
||||||
|
return p_scossl_shake_settable_ctx_param_types;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_shake_init(_Inout_ SCOSSL_DIGEST_CTX *ctx, ossl_unused const OSSL_PARAM params[])
|
||||||
|
{
|
||||||
|
SymCryptHashInit(ctx->pHash, ctx->pState);
|
||||||
|
ctx->xofLen = SymCryptHashResultSize(ctx->pHash);
|
||||||
|
|
||||||
|
return p_scossl_shake_set_ctx_params(ctx, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCOSSL_STATUS p_scossl_shake_extract(_Inout_ SCOSSL_DIGEST_CTX *ctx,
|
||||||
|
PSYMCRYPT_HASH_EXTRACT extractFunc, BOOLEAN wipeState,
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen)
|
||||||
|
{
|
||||||
|
if (outlen < ctx->xofLen)
|
||||||
|
{
|
||||||
|
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
|
||||||
|
return SCOSSL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
extractFunc(ctx->pState, out, ctx->xofLen, wipeState);
|
||||||
|
*outl = ctx->xofLen;
|
||||||
|
|
||||||
|
return SCOSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OSSL_FUNC_DIGEST_SQUEEZE
|
||||||
|
#define SCOSSL_DIGEST_SHAKE_SQUEEZE(bits) \
|
||||||
|
{OSSL_FUNC_DIGEST_SQUEEZE, (void (*)(void))p_scossl_shake_##bits##_squeeze},
|
||||||
|
#else
|
||||||
|
#define SCOSSL_DIGEST_SHAKE_SQUEEZE(bits)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IMPLEMENT_SCOSSL_SHAKE(bits) \
|
||||||
|
static SCOSSL_STATUS p_scossl_shake_##bits##_final( \
|
||||||
|
_In_ SCOSSL_DIGEST_CTX *ctx, \
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen) \
|
||||||
|
{ \
|
||||||
|
return p_scossl_shake_extract(ctx, \
|
||||||
|
(PSYMCRYPT_HASH_EXTRACT)SymCryptShake##bits##Extract, \
|
||||||
|
TRUE, \
|
||||||
|
out, outl, outlen); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SCOSSL_STATUS p_scossl_shake_##bits##_squeeze( \
|
||||||
|
_In_ SCOSSL_DIGEST_CTX *ctx, \
|
||||||
|
_Out_writes_bytes_(*outl) unsigned char *out, _Out_ size_t *outl, size_t outlen) \
|
||||||
|
{ \
|
||||||
|
return p_scossl_shake_extract(ctx, \
|
||||||
|
(PSYMCRYPT_HASH_EXTRACT)SymCryptShake##bits##Extract, \
|
||||||
|
FALSE, \
|
||||||
|
out, outl, outlen); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
SCOSSL_DIGEST_FUNCTIONS_COMMON(Shake##bits##Hash, shake_##bits, SCOSSL_DIGEST_FLAG_XOF) \
|
||||||
|
{OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))p_scossl_shake_set_ctx_params}, \
|
||||||
|
{OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, (void (*)(void))p_scossl_shake_settable_ctx_params}, \
|
||||||
|
{OSSL_FUNC_DIGEST_INIT, (void (*)(void))p_scossl_shake_init}, \
|
||||||
|
{OSSL_FUNC_DIGEST_FINAL, (void (*)(void))p_scossl_shake_##bits##_final}, \
|
||||||
|
SCOSSL_DIGEST_SHAKE_SQUEEZE(bits) \
|
||||||
|
SCOSSL_DIGEST_FUNCTIONS_END
|
||||||
|
|
||||||
|
//SHAKE
|
||||||
|
IMPLEMENT_SCOSSL_SHAKE(128)
|
||||||
|
IMPLEMENT_SCOSSL_SHAKE(256)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -132,6 +132,10 @@ extern const OSSL_DISPATCH p_scossl_sha512_functions[];
|
||||||
extern const OSSL_DISPATCH p_scossl_sha3_256_functions[];
|
extern const OSSL_DISPATCH p_scossl_sha3_256_functions[];
|
||||||
extern const OSSL_DISPATCH p_scossl_sha3_384_functions[];
|
extern const OSSL_DISPATCH p_scossl_sha3_384_functions[];
|
||||||
extern const OSSL_DISPATCH p_scossl_sha3_512_functions[];
|
extern const OSSL_DISPATCH p_scossl_sha3_512_functions[];
|
||||||
|
extern const OSSL_DISPATCH p_scossl_shake_128_functions[];
|
||||||
|
extern const OSSL_DISPATCH p_scossl_shake_256_functions[];
|
||||||
|
extern const OSSL_DISPATCH p_scossl_cshake_128_functions[];
|
||||||
|
extern const OSSL_DISPATCH p_scossl_cshake_256_functions[];
|
||||||
|
|
||||||
static const OSSL_ALGORITHM p_scossl_digest[] = {
|
static const OSSL_ALGORITHM p_scossl_digest[] = {
|
||||||
ALG("MD5:SSL3-MD5:1.2.840.113549.2.5", p_scossl_md5_functions),
|
ALG("MD5:SSL3-MD5:1.2.840.113549.2.5", p_scossl_md5_functions),
|
||||||
|
@ -142,6 +146,10 @@ static const OSSL_ALGORITHM p_scossl_digest[] = {
|
||||||
ALG("SHA3-256:2.16.840.1.101.3.4.2.8", p_scossl_sha3_256_functions),
|
ALG("SHA3-256:2.16.840.1.101.3.4.2.8", p_scossl_sha3_256_functions),
|
||||||
ALG("SHA3-384:2.16.840.1.101.3.4.2.9", p_scossl_sha3_384_functions),
|
ALG("SHA3-384:2.16.840.1.101.3.4.2.9", p_scossl_sha3_384_functions),
|
||||||
ALG("SHA3-512:2.16.840.1.101.3.4.2.10", p_scossl_sha3_512_functions),
|
ALG("SHA3-512:2.16.840.1.101.3.4.2.10", p_scossl_sha3_512_functions),
|
||||||
|
ALG("SHAKE-128:SHAKE128:2.16.840.1.101.3.4.2.11", p_scossl_shake_128_functions),
|
||||||
|
ALG("SHAKE-256:SHAKE256:2.16.840.1.101.3.4.2.12", p_scossl_shake_256_functions),
|
||||||
|
ALG("CSHAKE-128:CSHAKE128", p_scossl_cshake_128_functions),
|
||||||
|
ALG("CSHAKE-256:CSHAKE256", p_scossl_cshake_256_functions),
|
||||||
ALG_TABLE_END};
|
ALG_TABLE_END};
|
||||||
|
|
||||||
// Cipher
|
// Cipher
|
||||||
|
|
|
@ -1,140 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <openssl/core_dispatch.h>
|
|
||||||
#include <openssl/core_names.h>
|
|
||||||
#include <openssl/proverr.h>
|
|
||||||
|
|
||||||
#include "scossl_helpers.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const OSSL_PARAM p_scossl_digest_param_types[] = {
|
|
||||||
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, NULL),
|
|
||||||
OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_SIZE, NULL),
|
|
||||||
OSSL_PARAM_END};
|
|
||||||
|
|
||||||
const OSSL_PARAM *p_scossl_digest_gettable_params(ossl_unused void *dctx, ossl_unused void *provctx)
|
|
||||||
{
|
|
||||||
return p_scossl_digest_param_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCOSSL_STATUS p_scossl_digest_get_params(_Inout_ OSSL_PARAM params[], size_t blocksize, size_t size)
|
|
||||||
{
|
|
||||||
OSSL_PARAM *p = NULL;
|
|
||||||
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_size_t(p, blocksize))
|
|
||||||
{
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
|
||||||
return SCOSSL_FAILURE;
|
|
||||||
}
|
|
||||||
p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE);
|
|
||||||
if (p != NULL && !OSSL_PARAM_set_size_t(p, size))
|
|
||||||
{
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
|
|
||||||
return SCOSSL_FAILURE;
|
|
||||||
}
|
|
||||||
return SCOSSL_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lowercase, CamelCase, and UPPERCASE must be provided to reconcile differences
|
|
||||||
// between OpenSSL and SymCrypt APIs and macro definitions
|
|
||||||
#define IMPLEMENT_SCOSSL_DIGEST(lcalg, CcAlg, UCALG) \
|
|
||||||
static void *p_scossl_##lcalg##_newctx(ossl_unused void *prov_ctx) \
|
|
||||||
{ \
|
|
||||||
SCOSSL_COMMON_ALIGNED_ALLOC(dctx, OPENSSL_malloc, SYMCRYPT_##UCALG##_STATE); \
|
|
||||||
return (PBYTE)dctx; \
|
|
||||||
} \
|
|
||||||
static void *p_scossl_##lcalg##_dupctx(_In_ SYMCRYPT_##UCALG##_STATE *dctx) \
|
|
||||||
{ \
|
|
||||||
SCOSSL_COMMON_ALIGNED_ALLOC(copy_ctx, OPENSSL_malloc, SYMCRYPT_##UCALG##_STATE);\
|
|
||||||
\
|
|
||||||
if (copy_ctx != NULL) \
|
|
||||||
SymCrypt##CcAlg##StateCopy(dctx, copy_ctx); \
|
|
||||||
\
|
|
||||||
return copy_ctx; \
|
|
||||||
} \
|
|
||||||
static void p_scossl_##lcalg##_freectx(_Inout_ SYMCRYPT_##UCALG##_STATE *dctx) \
|
|
||||||
{ \
|
|
||||||
SCOSSL_COMMON_ALIGNED_FREE(dctx, OPENSSL_clear_free, SYMCRYPT_##UCALG##_STATE);\
|
|
||||||
} \
|
|
||||||
static SCOSSL_STATUS p_scossl_##lcalg##_init( \
|
|
||||||
_Inout_ SYMCRYPT_##UCALG##_STATE *dctx, \
|
|
||||||
ossl_unused const OSSL_PARAM params[]) \
|
|
||||||
{ \
|
|
||||||
SymCrypt##CcAlg##Init(dctx); \
|
|
||||||
return SCOSSL_SUCCESS; \
|
|
||||||
} \
|
|
||||||
static SCOSSL_STATUS p_scossl_##lcalg##_update( \
|
|
||||||
_Inout_ SYMCRYPT_##UCALG##_STATE *dctx, \
|
|
||||||
_In_reads_bytes_(inl) const unsigned char *in, \
|
|
||||||
size_t inl) \
|
|
||||||
{ \
|
|
||||||
SymCrypt##CcAlg##Append(dctx, in, inl); \
|
|
||||||
return SCOSSL_SUCCESS; \
|
|
||||||
} \
|
|
||||||
static SCOSSL_STATUS p_scossl_##lcalg##_final( \
|
|
||||||
_Inout_ SYMCRYPT_##UCALG##_STATE *dctx, \
|
|
||||||
_Out_writes_bytes_(SYMCRYPT_##UCALG##_RESULT_SIZE) unsigned char *out, \
|
|
||||||
_Out_ size_t *outl, size_t outsz) \
|
|
||||||
{ \
|
|
||||||
if (outsz < SYMCRYPT_##UCALG##_RESULT_SIZE) \
|
|
||||||
{ \
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL); \
|
|
||||||
return SCOSSL_FAILURE; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
SymCrypt##CcAlg##Result(dctx, out); \
|
|
||||||
*outl = SYMCRYPT_##UCALG##_RESULT_SIZE; \
|
|
||||||
return SCOSSL_SUCCESS; \
|
|
||||||
} \
|
|
||||||
static SCOSSL_STATUS p_scossl_##lcalg##_digest( \
|
|
||||||
ossl_unused void *provctx, \
|
|
||||||
_In_ const unsigned char *in, size_t inl, \
|
|
||||||
_Out_writes_bytes_(SYMCRYPT_##UCALG##_RESULT_SIZE) unsigned char *out, \
|
|
||||||
_Out_ size_t *outl, size_t outsz) \
|
|
||||||
{ \
|
|
||||||
if (outsz < SYMCRYPT_##UCALG##_RESULT_SIZE) \
|
|
||||||
{ \
|
|
||||||
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL); \
|
|
||||||
return SCOSSL_FAILURE; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
SymCrypt##CcAlg(in, inl, out); \
|
|
||||||
*outl = SYMCRYPT_##UCALG##_RESULT_SIZE; \
|
|
||||||
return SCOSSL_SUCCESS; \
|
|
||||||
} \
|
|
||||||
static SCOSSL_STATUS p_scossl_##lcalg##_get_params(_Inout_ OSSL_PARAM params[]) \
|
|
||||||
{ \
|
|
||||||
return p_scossl_digest_get_params(params, \
|
|
||||||
SYMCRYPT_##UCALG##_INPUT_BLOCK_SIZE, \
|
|
||||||
SYMCRYPT_##UCALG##_RESULT_SIZE); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
const OSSL_DISPATCH p_scossl_##lcalg##_functions[] = { \
|
|
||||||
{OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))p_scossl_##lcalg##_newctx}, \
|
|
||||||
{OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))p_scossl_##lcalg##_dupctx}, \
|
|
||||||
{OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))p_scossl_##lcalg##_freectx}, \
|
|
||||||
{OSSL_FUNC_DIGEST_INIT, (void (*)(void))p_scossl_##lcalg##_init}, \
|
|
||||||
{OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))p_scossl_##lcalg##_update}, \
|
|
||||||
{OSSL_FUNC_DIGEST_FINAL, (void (*)(void))p_scossl_##lcalg##_final}, \
|
|
||||||
{OSSL_FUNC_DIGEST_DIGEST, (void (*)(void))p_scossl_##lcalg##_digest}, \
|
|
||||||
{OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void))p_scossl_##lcalg##_get_params}, \
|
|
||||||
{OSSL_FUNC_DIGEST_GETTABLE_PARAMS, (void (*)(void))p_scossl_digest_gettable_params}};
|
|
||||||
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(md5, Md5, MD5)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha1, Sha1, SHA1)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha256, Sha256, SHA256)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha384, Sha384, SHA384)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha512, Sha512, SHA512)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha3_256, Sha3_256, SHA3_256)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha3_384, Sha3_384, SHA3_384)
|
|
||||||
IMPLEMENT_SCOSSL_DIGEST(sha3_512, Sha3_512, SHA3_512)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
Загрузка…
Ссылка в новой задаче