{"id":15691616,"url":"https://github.com/burnett01/openssl-cookie-secret-vault","last_synced_at":"2025-05-08T01:08:36.357Z","repository":{"id":44950409,"uuid":"61436413","full_name":"Burnett01/openssl-cookie-secret-vault","owner":"Burnett01","description":"A simple vault for storing cookie secrets that can be used while generating and verifying a cookie during the DTLS handshake procedure (HelloVerifyRequest, RFC6347) (https://tools.ietf.org/html/rfc6347#section-4.2)","archived":false,"fork":false,"pushed_at":"2022-01-16T17:05:54.000Z","size":41,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T01:06:23.900Z","etag":null,"topics":["cookie","cookie-secret","dtls","dtls-handshake-procedure","handshake","hmac","openssl","rfc-6347","vault","verify"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Burnett01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-18T14:10:37.000Z","updated_at":"2023-08-18T15:55:01.000Z","dependencies_parsed_at":"2022-09-06T14:40:06.920Z","dependency_job_id":null,"html_url":"https://github.com/Burnett01/openssl-cookie-secret-vault","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fopenssl-cookie-secret-vault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fopenssl-cookie-secret-vault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fopenssl-cookie-secret-vault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fopenssl-cookie-secret-vault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Burnett01","download_url":"https://codeload.github.com/Burnett01/openssl-cookie-secret-vault/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978758,"owners_count":21834915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookie","cookie-secret","dtls","dtls-handshake-procedure","handshake","hmac","openssl","rfc-6347","vault","verify"],"created_at":"2024-10-03T18:22:32.379Z","updated_at":"2025-05-08T01:08:36.314Z","avatar_url":"https://github.com/Burnett01.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openssl-cookie-secret-vault\n\nA simple vault for storing cookie secrets that can be used while generating and verifying a cookie during the DTLS handshake procedure (HelloVerifyRequest, RFC6347).\n\n\u003eThe DTLS server SHOULD generate cookies in such a way that they can\n\u003ebe verified without retaining any per-client state on the server.\n\u003e\n\u003eOne technique is to have a randomly generated secret and generate\n\u003ecookies as:\n\u003e\n\u003eCookie = HMAC(Secret, Client-IP, Client-Parameters)\n\u003e\n\u003eWhen the second ClientHello is received, the server can verify that\n\u003ethe Cookie is valid and that the client can receive packets at the\n\u003egiven IP address.  In order to avoid sequence number duplication in\n\u003ecase of multiple cookie exchanges, the server MUST use the record\n\u003esequence number in the ClientHello as the record sequence number in\n\u003eits initial ServerHello.  Subsequent ServerHellos will only be sent\n\u003eafter the server has created state and MUST increment normally.\n\u003e\n\u003eOne potential attack on this scheme is for the attacker to collect a\n\u003enumber of cookies from different addresses and then reuse them to\n\u003eattack the server.  The server can defend against this attack by\n\u003echanging the Secret value frequently, thus invalidating those\n\u003ecookies.  If the server wishes that legitimate clients be able to\n\u003ehandshake through the transition (e.g., they received a cookie with\n\u003eSecret 1 and then sent the second ClientHello after the server has\n\u003echanged to Secret 2)\n\nRFC: https://tools.ietf.org/html/rfc6347\n\n---\n\n### Solution / How it works\n\nInstead of storing cookies or using the same secret over and over again, we simply generate a specific amount of secrets, store them inside a vault and randomly pick one upon cookie-creation.\nLater then we match the cookie against our secrets in that vault.\n\n**Please note:** This solution does not reflect the most appropiate way as described in RFC 4347, where only 2 self-invalidating secrets should be used. My solution should therefor only be looked as a tool for implementing the RFC.\u003cbr\u003e\nThank's to Nathaniel J. Smith for clarifying this fact.\n\n---\n\n### Source code\n\nTwo versions namely stack and heap are included.\n\n#### Stack version: [Here](../master/stack/)\n\n#### Heap version: [Here](../master/heap/)\n\n---\n\nRequirements:\n\n```c\n#include \u003copenssl/crypto.h\u003e\n#include \u003copenssl/rand.h\u003e\n#include \u003copenssl/evp.h\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fopenssl-cookie-secret-vault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburnett01%2Fopenssl-cookie-secret-vault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fopenssl-cookie-secret-vault/lists"}