Keygen Tag in HTML5

In this article I am going to describe about the Implementation and Use of Keygen Tag in HTML5
  • 2501

 Keygen Tag

<keygen> tag is new in HTML5.This tag is not supported by previous version of HTML. This tag is used with a <form> tag. When the form processes <keygen> will generate a public and private encrypted key.

<keygen> tag specifies a key pair generator field which is to be used by the forms. When the form is submitted private key is stored locally and the public key is sent to the server. In other words,<keygen> is a public/private keypair generation utility used in web forms to prevent "session hijacking" by creating signed certificates as an authentication method.

Benefits and Drawbacks of Keygen Tag in HTML5


  • It can improve security when authenticating.
  • <keygen> tag is implemented across non-IE browsers, making it easy to implement.
  • If used as a "client certificate",it ca make MITM attacks much more difficult.


  • Private key is not stored in a standard location.
  • <keygen>does not provide a mechanism for managing certificate expiry.
  • certificate is limited to RSA based application.
  • No standard key length or hash implemented across browsers.

Browsers supporting <keygen> tag

<keygen> tag is supported in all major browser except Internet Explorer.

Attributes of Keygen Tag

    Attribute     Value     Description
   autofocus autofocus specifies that a <keygen> element should automatically get focus when the page loads.
   disabled disabled specifies that the <keygen> element should be disabled.
   challenge challenge specifies that the value of the <keygen>element should be challenge when submitted.
   form name of  the  form specifies one or more form the <keygen> element belongs to.
   keytype rsa,dsa,ec specifies the security algorithm of the key.
   name name specifies the name of the <keygen> element.

Example of <keygen> tag in HTML5

<!DOCTYPE html>

<html lang="en" xmlns="">


    <title>Keygen Tag in HTML5</title>

    <form id="myform" action="test.aspx" method="get">


        <input type="text" name="username" />

        Roll No: <keygen name="security" keytype="rsa" form="myform" autofocus />

        <input type="submit" />




    <p>keygen tag is new in html5</p>





© 2020 DotNetHeaven. All rights reserved.