summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authorYusuke Nakamura <unasuke@users.noreply.github.com>2021-06-27 16:37:18 +0900
committerKazuki Yamaguchi <k@rhe.jp>2021-07-18 17:48:49 +0900
commit11651ab703336744b47174568b168900dd4590e8 (patch)
tree1d81f27663acc1305dbfd38e998999400f4bbc62 /ext/openssl
parent70f0a802fee58b7795b81f0273cee1c9bf8b1bd3 (diff)
[ruby/openssl] Add example to OpenSSL::KDF.hkdf method (https://github.com/ruby/openssl/pull/447)
The values from RFC 5869 https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1 https://github.com/ruby/openssl/commit/ec14a87f4f
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_kdf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/openssl/ossl_kdf.c b/ext/openssl/ossl_kdf.c
index 486e789458d..7fa38b865e4 100644
--- a/ext/openssl/ossl_kdf.c
+++ b/ext/openssl/ossl_kdf.c
@@ -163,6 +163,14 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
* HashLen is the length of the hash function output in octets.
* _hash_::
* The hash function.
+ *
+ * === Example
+ * # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1
+ * ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*")
+ * salt = ["000102030405060708090a0b0c"].pack("H*")
+ * info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*")
+ * p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*")
+ * # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865"
*/
static VALUE
kdf_hkdf(int argc, VALUE *argv, VALUE self)