# Grsecurity/Obtaining grsecurity

The following instructions will lead you through the process of downloading all the components necessary for using grsecurity on your system. Download each component to the same directory on your computer.
You need:
* The latest stable version of grsecurity.
* A matching version of gradm, the administration utility for grsecurity.
* Full source code of the Linux kernel.
You also need to have necessary programs for building, configuring and installing a custom kernel for your system. The preferred way, and required tools, to do the installation depend on the Linux distribution you are using. If you encounter problems with configuring or installing the kernel, please consult your distribution's documentation.

## Downloading grsecurity

Point your browser to http://grsecurity.net/. Click on the "Download" link and then select a "Stable" or "Test" patch (since September 9th, 2015, stable patches of grsecurity are available to commercial customers only). For the purposes of this document, we will be installing the latest stable grsecurity for kernel 3.2.50. Therefore the patch file will be called "grsecurity-2.9.1-3.2.50-201308052151.patch".
In our case we downloaded the following files
* grsecurity-2.9.1-3.2.50-201308052151.patch
* grsecurity-2.9.1-3.2.50-201308052151.patch.sig - This is the digital signature of this release.

## Downloading gradm

When downloading gradm, the administration utility for grsecurity's role-based access control system, you must download the version that matches the version of the grsecurity patch you downloaded. Gradm is located on the same download page as grsecurity.
In our case we downloaded the following files
* gradm-2.9.1-201308021745.tar.gz
* gradm-2.9.1-201308021745.tar.gz.sig - This is the digital signature of this release.

## Downloading the Linux Kernel

The grsecurity patches can only be applied to a vanilla kernel. Many distributions modify the official kernel with additional patches, which means that any kernel source packages acquired through their package manager is very likely incompatible with grsecurity.
For this reason we will download the official unmodified kernel from http://www.kernel.org/. Download the full kernel source package and its signature (the ".sign" file), and make sure its version matches the version of the grsecurity patch you downloaded. In this document the version is 3.2.50. The required version is most likely not the latest, so you need to get it from the kernel archives.
* Official support for kernel version 2.6.32.61 closed at the end of 2013.
If you've got a terminal open, you can use the below commands to download both the kernel source and the signature to the current working directory:
NOTE: The versions of the grsecurity patch and the kernel must match exactly.

## Verifying the Downloads

The grsecurity and gradm packages have been cryptographically signed so that users can verify that the source code has not been modified since it was packaged. You can find the public key used to sign them from the same download page as grsecurity. Scroll down the page until you see a heading that says "Verify these downloads with GPG". Below the heading is a link to the public key. Download the key to the directory where you placed grsecurity.
Before you can verify the downloads, you need to import the grsecurity key to your public keyring using Gnu Privacy Guard (GPG). If you are unfamiliar with GPG and wish to know more, please refer to The GNU Privacy Handbook.
To import the key, run the following command in the directory where your grsecurity and its key were downloaded.
After importing the key, verify the downloaded grsecurity and gradm packages by running the below commands in your grsecurity directory:
Below is an example of a failed signature verification. The patch file was modified on purpose to make the verification fail.
As long as GPG reports the signature is good, you do not need to worry about the warning about the key not being certified with a trusted signature. If you signed the grsecurity key with your own key, you will not get the warning. If the verification of either file failed (i.e. if you get the "BAD signature" message), re-download the file in question and try again.
The Linux kernel source packages have been signed as well. Please follow the instructions on the Linux kernel website to verify the kernel source package.
When you have successfully verified the downloaded files, you are ready to configure grsecurity.