Skip to content

9618 · Unit 6 · Paper 1: Theory fundamentals

Security, privacy and data integrity.

9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Security, privacy and integrity of data

§6.1 · Data security · definitions

One employee’s record on a company server can go wrong in three ways: it can be lost, read by the wrong person, or simply be wrong. A record can be kept safe and private and still hold a mistake, so each concern needs its own measures.

Follow each row from the record: the concern, what can go wrong, and the measure that protects it.

One stored recordConcernWhat can go wrongMeasure that protects itEmployee recordID1042NameA. MensahSalary31 500Address4 Mill Laneheld on the HR serverSecurityno loss or corruptionDisk failsthe only copy is lostBackuprestore from a copy kept elsewherePrivacyauthorised people onlyUnauthorised accessa colleague reads all salariesAccess rightsonly payroll staff can read salariesIntegrityaccurate, up to dateTyping errorsalary saved as 351 500Validation, verificationrange check; compare with originalEmployee record · A. Mensah · ID 1042Security: prevent loss or corruptionDisk failure loses the only copyBackup → restore a separate copyPrivacy: authorised people onlySalary: 31 500; address: 4 Mill LaneA colleague reads confidential salariesAccess rights → payroll staff onlyIntegrity: accurate and up to dateSalary mistyped as 351 500Range check flags an implausible salaryCompare the entry with the original

Definitions

The three terms sound alike, so the bold words carry the difference: use them when you define each one.

TermMeaning: the wording to useTypical measures
Security of datakeeping data safe from loss or corruption, so it is there when needed and can be recoveredbackups, firewall, anti-malware, passwords, access rights
Privacy of dataonly authorised people can read the data or be given itaccess rights, encryption
Integrity of datamaking sure data is accurate, consistent and up to datevalidation and verification

Protect the data and the system

Protect the data

  • An intruder can read, copy, change or delete it.
  • It can be lost by accident: a disk failure, a file deleted in error, fire or flood.
  • A business cannot work without it, so it must be recoverable.

Protect the system

  • An intruder can plant malware or stop the system working.
  • Staff need it running for their daily jobs.
  • Logging in is for authorised users alone.
Your turn

1 A hospital’s only copy of its patient records is on one disk, which fails. Which concern is this: security, privacy or integrity?

2 A patient’s date of birth is stored as 31/02/1990. Which concern is this, and which measure would catch it?

3 Give one measure for privacy and say how it protects the data.

  1. 1
    security: the data is lost; a backup kept elsewhere lets it be recovered
  2. 2
    integrity: the data is not accurate; validation (a check that the date exists) would reject it
  3. 3
    access rights: only authorised users can read the records (or encryption: a copy cannot be understood without the key)
Tick what you can do now
Exam focusKeep the three apart: security keeps data safe from loss or corruption; privacy stops unauthorised access or disclosure; integrity means the data is accurate and up to date. Firewalls, passwords and access rights count as security measures; a presence check or double entry counts as an integrity measure.
Practise with s21/12 Q8(a) (older paper); w21/11 Q2(a) (older paper); w21/12 Q1 (older paper); s22/12 Q4(a) (older paper)
1 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Threats: viruses, spyware and hackers

§6.1 · Data security · threats from networks and the internet

Once a computer is connected to the internet, anything out there can try to reach it. Viruses and spyware are malware (malicious software); hackers are people who break in. All three come in through the network and internet connection.

Follow each threat from 1 to 3: how it gets in, what it does, and the harm (amber).

Virusmalware1Infected program is rune.g. opened from an email2Copies itselfinto other programs and files3Data deleted or corruptedstorage can fill upSpywaremalwarepa55…1Installed unnoticedhidden in a free download2Records keystrokespasswords, card numbers3Log sent to a third partyover the internetHackera person1Person outsideconnects over the internet2Gets past securitye.g. guesses a weak password3Unauthorised accessreads, changes or deletes dataVirusmalware1Infected program is rune.g. opened from an email2Copies itselfinto other programs and files3Data deleted or corruptedstorage can fill upSpywaremalwarepa55…1Installed unnoticedhidden in a free download2Records keystrokespasswords, card numbers3Log sent to a third partyover the internetHackera person1Person outsideconnects over the internet2Gets past securitye.g. guesses a weak password3Unauthorised accessreads, changes or deletes data
VirusmalwareInfected program runse.g. opened from an emailCopies itselfinto other programs and filesData deleted or corruptedstorage can fill upSpywaremalwareInstalled unnoticedhidden in a free downloadRecords keystrokespasswords, card numbersLog sent to a third partyover the internetHackera personPerson outsideconnects over the internetGets past securitye.g. guesses a weak passwordUnauthorised accessreads, changes or deletes dataVirusInfected program runse.g. opened from an emailCopies itselfinto other programs and filesData deleted or corruptedstorage can fill upSpywareInstalled unnoticedhidden in a free downloadRecords keystrokespasswords, card numbersLog sent to a third partyover the internetHackerPerson outsideconnects over the internetGets past securitye.g. guesses a weak passwordUnauthorised accessreads, changes or deletes data

Describe the threat, then a matching method

For each threat, be able to say what it does and give a method that stops that threat.

ThreatWhat it isA method that restricts it, and how it works
Virusmalware that replicates (copies itself into other files) and can delete or corrupt data or fill storageAnti-virus. How: checks each file and download, matches it against signatures of known viruses, quarantines or deletes a match
Spywaremalware that hides on the computer, secretly records keystrokes and passes them to a third partyAnti-spyware finds and removes it. Also: a firewall stops the log going out; a virtual keyboard leaves no keystrokes to record
Hackera person who gets into a system without permission: unauthorised accessFirewall. How: tests traffic in and out against rules and blocks what breaks them. Also: strong passwords; multi-factor or biometric authentication

Virus or spyware?

Both are hidden malware, so three questions tell them apart: does it copy itself, what does it do to data, and does it send anything out?

VirusSpyware
Copies itself?yes: it replicates into other filesno
What it does to datadamages it: deletes or corrupts filesrecords it: keystrokes, passwords, card numbers
Sends data out?noyes, to a third party
Both are malware hidden from the user, often inside a program that looks genuine, and both work unseen while the user carries on.
Your turn

1 A program copies itself into every document on a shared drive. Which threat is it?

2 Name a method that stops spyware sending its log, and say how.

3 Give two different methods that restrict hacking.

  1. 1
    a virus: it replicates into other files
  2. 2
    a firewall: it checks outgoing traffic against rules and blocks the log leaving (or anti-spyware finds and removes it)
  3. 3
    any two: a firewall that blocks traffic breaking its rules; strong passwords; multi-factor or biometric authentication
Tick what you can do now
Exam focusSay what the threat does: a virus replicates and deletes or corrupts data (“causes harm” earns nothing); a hacker gets unauthorised access (“malicious intent” alone earns nothing). Then describe a method that matches the threat; when two are asked for, give two different ones.
Practise with s26/12 Q2(c)(i), (c)(ii); w25/12 Q5(e); w21/11 Q2(c) (older paper)
2 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Threats: phishing and pharming

§6.1 · Data security · threats from networks and the internet

A fake bank website can look exactly like the real one. Phishing and pharming both trick a user into typing confidential details into a fake website. They differ in how the user gets there.

Follow both routes: a message the user acts on (blue), or code that redirects a correct address (violet). Both end at the same fake site.

Phishing · the user acts on a messageemail posingas Leaflineuser clicksits linkPharming · the request is redirectedleafline.examplemalicious codecode redirects the requestthe user typed the correct addressFake websitea copy of Leafline’s pageleafline.exampleLog inj.lee••••••••data stolenfor fraud oridentity theftPhishing · the user acts on a messageemail posing as Leaflineuser clicks its linkPharming · the request is redirectedleafline.examplemalicious codeuser clickscode redirectsBoth reach the fake websiteleafline.exampleLog inj.lee••••••••data stolenused for fraud or identity theft

Compare the two

The two are easy to mix up because they end at the same fake site. Be able to give one similarity and one difference: the difference is always the route.

PhishingPharming
How it startsa message posing as a trusted organisationmalicious code installed on the user’s PC
To the fake sitethe user clicks a link in the message: user action is neededthe code redirects the request automatically, even when the genuine address is typed
Aimto collect personal or financial datathe same
Restrict the riska spam filter; ignore unknown sendersanti-malware removes the code; also a VPN

Identify the route to Leafline’s fake site

Leafline is an online plant shop. Some customers lose reward points after clicking a message link; others typed its correct address.

Observed routeThreat and reason
Clicked a message posing as LeaflinePhishing: the user acted on the deceptive message.
Typed the correct address but was redirectedPharming: installed code redirected the request.

Both routes reach a fake copy that collects login details. A fake website is their similarity; the route to it is their difference.

Your turn

1 A text message says a parcel is held and links to a payment page. Phishing or pharming? Why?

2 A user types the correct address of their bank and still reaches a fake site. Which threat is this, and what caused it?

3 Give one way to restrict each threat.

  1. 1
    phishing: it is a message, and the user must act on it by following the link
  2. 2
    pharming: malicious code installed on the computer redirected the request
  3. 3
    phishing: a spam filter, or do not follow links in unexpected messages; pharming: anti-malware that removes the redirecting code
Tick what you can do now
Exam focusAsked for a difference? Contrast the route to the fake site, never the site itself: an action by the user (phishing) or a silent redirect by installed code (pharming).
Practise with w25/11 Q8(a); w25/12 Q5(e); w23/13 Q8(b) (older paper)
3 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

User accounts, passwords and authentication

§6.1 · Data security · security measures

A computer cannot see who is at the keyboard. A user account gives each person a username, a password and their access rights. Authentication checks that the person logging in really owns the account.

Two checks in order: something the user knows, then a second factor. Fail either and access is denied.

Log inj.lee••••••••1 · username + passwordsomething the user knows✓ matchcode3067182 · second factorapp code or fingerprint✓ matchaccess grantedwith this account’s rights✗ no match at either check → access denied; repeated failures can lock the accountLog inj.lee••••••••1 · username + passwordsomething the user knows✓ matchcode3067182 · second factorapp code or fingerprint✓ matchaccess grantedwith this account’s rights✗ No match at either check → access deniedRepeated failures can lock the account

Three kinds of authentication factor

Something you know

A password or PIN. No extra hardware, but it can be guessed, seen or forgotten.

Something you have

A phone with an authenticator app, a security token or a key card: an attacker must steal it too.

Something you are

Biometrics: fingerprint, face, iris or voice. Unique to the person and very hard to copy.

Multi-factor (two-factor) authentication asks for factors of two different kinds, such as a password and a code from an authenticator app. A stolen password on its own is then not enough.

Why long, varied passwords?

A program can try every possible password in turn: possible passwords = (characters allowed)length. Times assume 10 billion guesses a second.

Characters allowedHow manyLengthPossibleTime to try all
a–z only2682.09 × 101121 seconds
a–z, A–Z, 0–96282.18 × 10146.1 hours
all keyboard characters9486.10 × 10157.1 days
all keyboard characters94124.76 × 10231.5 million years

A strong password

  • At least a set number of characters.
  • A mixture of upper and lower case, digits and symbols.
  • Nothing connected to the user, such as a date of birth.
  • Not reused for other accounts.
Your turn

1 A bank asks for a password and then a fingerprint. Which two kinds of factor are these?

2 A PIN uses the digits 0 to 9 and has 4 digits. How many PINs are possible?

3 Why is a password and a security question not multi-factor authentication?

  1. 1
    something the user knows (password) and something the user is (biometric)
  2. 2
    104 = 10 000
  3. 3
    both are something the user knows: multi-factor needs two different kinds
Tick what you can do now
Exam focusName the method and describe it: multi-factor authentication needs a second form of verification, such as a code from an authenticator app or a biometric; “uses authentication” alone earns nothing. Biometrics use features unique to the person that are almost impossible to copy.
Practise with s26/12 Q2(c)(ii); w25/13 Q5(d); w25/11 Q5(a)(ii)
4 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Firewalls, anti-virus and anti-spyware

§6.1 · Data security · security measures

Not every packet from the internet should get in, and not every packet should leave. A firewall, in hardware or software, sits between a computer or network and the outside world and checks every packet going in or out. Anti-virus and anti-spyware find malicious software in files and downloads, and remove it or stop it arriving.

Applying the rules to five packets

Check each packet against the rules in order: the first rule that matches decides. Be able to do this for a new packet.

Rules, checked in order · deny list: 203.0.113.66

Rule 1  Block any packet to or from an address on the deny list
Rule 2  Allow incoming web traffic (port 443) to the web server
Rule 3  Allow outgoing web traffic (port 443)
Rule 4  Block everything else
INTERNETSCHOOL NETWORKFirewallrule 21198.51.100.4 → web server:443✓ allowed inrule 12203.0.113.66 → web server:443✗ blockedrule 43198.51.100.4 → PC 12:23✗ blockedrule 14PC 7 spyware → 203.0.113.66:443blocked ✗rule 35PC 3 → 198.51.100.20:443allowed out ✓Packet 1 · incoming198.51.100.4 →web server:443Rule 2: allowed inPacket 2 · incoming203.0.113.66 →web server:443Rule 1: blockedPacket 3 · incoming198.51.100.4 →PC 12:23Rule 4: blockedPacket 4 · outgoingPC 7 spyware →203.0.113.66:443Rule 1: blockedPacket 5 · outgoingPC 3 →198.51.100.20:443Rule 3: allowed out

Packet 4 shows why outgoing traffic is checked too: spyware trying to send its log to a blocked address is stopped.

Scanning for malware

Anti-virus and anti-spyware

1
Scan files, downloads and memory, on demand or on a schedule.
2
Match what it finds against the signatures of known viruses and spyware.
3
On a match: quarantine or delete the file and alert the user; a download can be stopped.
4
Update the signatures regularly, or newly released malware will not be recognised.

Do not confuse

A firewall does not scan the files already on a disk for viruses, and anti-virus software does not block a hacker’s connection. Anti-spyware is the tool aimed at spyware; anti-malware covers every kind.

Your turn

1 Use the four rules. An incoming packet from 198.51.100.4 is sent to the web server on port 80. Which rule decides, and is it allowed?

2 An outgoing packet from PC 9 to 198.51.100.20 on port 443?

3 An incoming packet from 203.0.113.66 to PC 3 on port 443?

4 Why must anti-virus signatures be updated regularly?

  1. 1
    rule 4: blocked: port 80 matches neither allow rule
  2. 2
    rule 3: allowed
  3. 3
    rule 1: blocked: the address is on the deny list, and rule 1 is checked first
  4. 4
    new malware has signatures the old list does not contain, so it would not be recognised
Tick what you can do now
Exam focusFirewall, three parts: 1 it watches traffic both ways, in and out; 2 it tests each packet against rules (IP addresses, ports); 3 it blocks what fails. Anti-virus, three parts: 1 scan; 2 match against known malware; 3 quarantine or delete.
Practise with s24/11 Q5(c)(i); s24/12 Q3(a)(i); s26/12 Q2(c)(i)
5 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Encryption, access rights and backups

§6.1 · Data security · protecting data

A password can be beaten and a disk can fail, so some measures protect the data itself: encryption makes it unreadable, access rights limit who can use it, and backups let it be recovered.

Encryption: intercepted data cannot be understood

Follow the message across the network: anyone who intercepts it sees only the ciphertext. The receiver needs the key to turn it back into plaintext.

SenderReceiverCiphertextPHHW DW QRRQSender’s key: 3ciphertext sent across the networkIntercepted: cannot be understoodPlaintextMEET AT NOONReceiver’s key: 3Toy shift only; strong encryption needs a secure key.SenderReceiverCiphertextPHHW DW QRRQSender’s key: 3ciphertextsent acrossthe networkIntercepted: cannot be understoodPlaintextMEET AT NOONReceiver’s key: 3Toy shift only; strong encryption needs a secure key.

Stored data

An encrypted disk, file or database cannot be read by anyone who copies or steals it without the key.

Transmitted data

Data sent over a network is encrypted, e.g. HTTPS or a VPN, so intercepted data is meaningless.

Access rights: what each user may do

Read down one column to see everything a single user may do, or across a row to see who can change that file.

FileStudentTeacherExams officer
Timetableread-onlyread-onlyread/write
Class marksno accessread/writeread-only
Exam papers before the examno accessno accessread/write

Each account or group gets no access, read-only, or read and write for each file or table. Logging in does not give access to everything. In a database, a view can show a user only some of the data.

Backups and physical security

Backups

Regular copies kept in a separate place mean data can be recovered after a disk failure, a mistaken deletion, malware or fire. A backup does not prevent the loss.

Physical security

Lock the room that holds the server, and log off or lock a computer before leaving it, so no one can simply sit down and use it.

Your turn

1 Use the toy shift of 3 to encrypt the word LOCK.

2 Using the table, what may a teacher do with the timetable, and with the exam papers?

3 A file server is encrypted and backed up every night. A fire destroys the server room. Which measure lets the school carry on, and why?

  1. 1
    ORFN: each letter moves 3 places on
  2. 2
    timetable: read-only; exam papers: no access
  3. 3
    the backup, if it is kept in a separate place: the data can be restored. Encryption does not prevent the loss
Tick what you can do now
Exam focusFor encryption make three points: data is encoded into ciphertext using an algorithm and a key; if it is intercepted it cannot be understood without the decryption key. Encryption does not stop interception. For access rights, name the levels: no access, read-only, read and write.
Practise with s25/11 Q7(a); s25/12 Q5(c)(i); w25/13 Q5(d); s26/12 Q3(c)
6 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Digital signatures

§6.1 · Data security · authentication techniques

A program you download says it comes from its maker, but it could have come from anyone, or been changed on the way. A digital signature lets the receiver check that a document really came from the claimed sender (authentic) and that it was not changed on the way.

Follow the sender’s two steps (hash, then encrypt the digest), then the receiver’s three (decrypt, hash again, compare). Name the key used at each step.

SENDERRECEIVERDocumentPay 250 toJ. OkaforhashDigestde2ed590…SHA-256, shortenedencrypt digestSignatureencrypted digestSender’s private keydocument + signature sentDocumentPay 250 toJ. OkaforSignaturedecryptSender’s public keyDigest 1de2ed590…same hash algorithmDigest 2de2ed590…Equal digestsauthentic and unchangedDifferent digests → reject. Signing does not hide the document.SENDERRECEIVERDocumentPay 250 toJ. OkaforhashDigestde2ed590…SHA-256, shortenedencryptSignatureencrypted digestSender’s private keydocument + signature sentDocumentPay 250 toJ. OkaforSignaturedecryptSender’s public keyDigest 1de2ed590…hashDigest 2de2ed590…Equal digestsauthentic and unchangedDifferent digests → reject. Signing does not hide the document.

Hashing: a small change gives a completely different digest

Only one digit of the amount differs between the two documents. Compare their digests.

DocumentSHA-256 digest (first 24 of 64 hex digits)
Pay 250 to J. Okaforde2ed590ca5782d6492d2e5b…
Pay 850 to J. Okafor7049b97bfd90f09ef05dd8e5…
Document and its SHA-256 digest
Pay 250 to J. Okafor
de2ed590ca5782d6492d2e5b…
Pay 850 to J. Okafor
7049b97bfd90f09ef05dd8e5…
First 24 of 64 hexadecimal digits shown.

The two digests agree in only 1 of the 24 digits shown, by chance. An altered document gives a different digest 2, so the comparison at step 6 fails.

What it proves

  • Authentic: the private key is held by the sender alone, so a signature that decrypts with their public key to the right digest must have come from them.
  • Unchanged: any change to the document gives a different digest 2.

Do not confuse

  • The digest is encrypted, not the whole document.
  • Private key signs; the matching public key checks.
  • A signature does not hide the document: encrypt it as well if it is confidential.
Your turn

1 Which key does the sender use to make the signature? Which key does the receiver use to check it?

2 On the way, “Pay 250” is changed to “Pay 850”. What does the receiver find when it compares the digests?

3 Does a digital signature keep the document secret? Explain.

  1. 1
    the sender’s private key signs (encrypts the digest); the sender’s public key checks (decrypts it)
  2. 2
    digest 2, from the changed document, differs from digest 1, so the document is rejected
  3. 3
    no: the document travels readable. It must also be encrypted to keep it secret
Tick what you can do now
Exam focusName each item. Sender: hash the document to a digest, then encrypt the digest with the sender’s private key. Receiver: decrypt the signature with the sender’s public key, hash the document as received with the same algorithm, then compare. Equal digests: authentic and unchanged.
Practise with s25/11 Q7(b); w25/12 Q10(c); w22/12 Q6(a)(i) (older paper)
7 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Security measures for stand-alone computers and networks

§6.1 · Data security · restricting the risks

Link thirty computers into a network and there are more ways in and more users. So a network needs a firewall at the router, and accounts, rights and backups set on the server.

Start with the measures one computer needs. Then follow traffic in from the internet: it must pass the firewall before it reaches the server or a client PC.

Stand-alone PC · one useruser account, strong passwordanti-virus and anti-spywareencrypted diskbackups kept on another driveupdates installed promptlylock the room; log off when awayNetwork of computershackers, malware,phishing emailsInternetRouter with firewallevery packet in or outpasses the firewallSwitchServer: accounts,rights, backups, logsClient PCs: anti-malware,no admin rightsData in transit: encrypted (HTTPS, VPN)Stand-alone PC · one user• user account, strong password• anti-virus and anti-spyware• encrypted disk• backups kept on another drive• updates installed promptly• lock the room; log off when awayNetwork of computersHackers, malwareand phishingInternetRouter + firewallchecks every packetdata links: encrypt(HTTPS, VPN)SwitchServeraccounts and rightsbackups and logsClient PCsanti-malwareno admin rights
Stand-alone PCPCone useruser account, strong passwordanti-virus and anti-spywareencrypted diskbackups on a drive kept elsewhereupdates installed promptlylock the room; log off when awayNetwork of computersInternetRouterwith firewall:filters trafficSwitchServeraccounts, rights,backups, logsClient PCsanti-malware,no admin rightshackers, malware,phishing emailsevery packet in or outpasses the firewallData in transit: encrypted (HTTPS, VPN)Stand-alone PC · one user• User account and strong password• Anti-virus and anti-spyware• Encrypted disk• Backup drive kept elsewhere• Install updates promptly• Lock the room; log off when awayNetwork of computersInternetHackers, malwareand phishingRouter + firewallChecks every packetin and outData links: encryptwith HTTPS / VPNSwitchServerAccounts and rightsBackups and logsClient PCsAnti-malwareNo admin rights

Measures for stored data and for data in transit

First ask where the data is: sitting on a disk, or travelling across a network. Each needs its own protection.

DataMeasuresHow each protects it
Stored on a PC or serverphysical security; access rights; an encrypted disk; backupsno one can sit down and copy it; only allowed users can open it; a stolen copy is unreadable; a lost copy can be restored
Sent over a networkencryption (e.g. over a VPN); a firewallan intercepted copy cannot be understood without the key (a firewall blocks traffic but does not hide content)

Reducing the malware risk

Each row gives a measure and why it lowers the risk: give both.

WhereMeasureWhy the risk falls
Network connectiona firewall compares data in and out with set rules and blocks what is not allowedfewer ways in
Downloadssoftware only from trusted, official sitesfewer files carry hidden malware
USB drivesa portable-storage policy: block or scan drivesinfected files are not copied in
User accountsstrong passwords; multi-factor authentication (app code or biometrics); no admin rightsa stolen password alone is not enough; malware cannot install itself
Files on the PCanti-malware, signatures updated dailyknown malware is found and quarantined
Your turn

1 A school links 30 PCs to the internet. Where should the firewall go, and why there?

2 Give two different measures that protect data sent over the network.

3 Why does a user with no admin rights lower the malware risk?

  1. 1
    at the router, between the school network and the internet: every packet in or out passes it
  2. 2
    encryption (for example over a VPN), so an intercepted copy cannot be understood; a firewall, which blocks traffic that breaks its rules
  3. 3
    malware run by that user cannot install itself or change system settings
Tick what you can do now
Exam focusGive the method and how it lowers the risk: “anti-malware with updated signatures finds known malware and quarantines it”. Asked for different methods? Never repeat one.
Practise with s26/12 Q2(c)(i), (c)(ii); s25/13 Q3(b); s25/11 Q7(a); w25/13 Q5(d); w23/13 Q8(c) (older paper)
8 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Validation and verification

§6.2 · Data integrity

A stored value is only useful if it is right. Errors get into data at two points: when it is entered and when it is transferred. Validation and verification both guard against them, but they ask different questions.

One check asks “is it reasonable?”, the other “is it the same as the original?”. Follow one quantity, 4075, as it is typed wrongly: the first lets it through, the second catches it.

DATA ENTRYOriginalon the delivery note4075Typed intwo digits swapped4057Validation: is it reasonable?a whole number from 0 to 9999Verification: same as the original?compare with the note: 4057 ≠ 4075Error gets throughvalidation passes itError caughtthe quantity is re-enteredDATA TRANSFERSenderadds parity bits or a checksumTransmissiona bit may be flippedReceiverrecalculates and comparesverificationData entry · original 4075 → typed 4057Validation: whole number, 0 to 99994057 obeys the ruleWrong value gets throughVerification checks the same entryCompare with original: 4057 ≠ 4075The difference is detectedRe-enter the quantityData transferSender adds parity bits or a checksumTransmission can change a bitReceiver recalculates and compares

Validation compared with verification

Neither check catches every mistake, which is why a system often uses both. Be able to say which one a method is, and what each can still let through.

ValidationVerification
Tests…the data against set rules (bounds, format, type): is it reasonable?the data against the original, or that it did not change in transfer: is it the same?
Carried out bysoftware, automatically, as data is entereda person or the computer at entry; the receiver after a transfer
Methodsrange, format, length, presence, existence, limit, check digitentry: visual check, double entry · transfer: parity byte, parity block, checksum
Lets througha wrong value that still obeys the rules, such as 4057 for 4075an original that was itself wrong; the same mistake typed twice
Your turn

1 An age must be from 0 to 120. A form shows 71, but 17 was typed. Will a range check reject 17? Why?

2 Which method would catch it, and how?

3 Give one reason data can be wrong after both validation and verification.

  1. 1
    no: 17 is in range, so it is reasonable
  2. 2
    verification: a visual check against the form, or double entry
  3. 3
    the original document was itself wrong (or the same wrong value was entered twice, and it is valid)
Tick what you can do now
Exam focusWhy can data still be wrong after both checks? “The original was incorrect” or “the same wrong data was entered twice and is valid” earn marks; “user error” alone and “data as intended” do not.
Practise with s26/11 Q4(d)(i), (d)(ii); s26/12 Q2(a); w25/12 Q1; s26/13 Q1; w25/13 Q7(c)
9 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Verification during data entry

§6.2 · Data integrity · data verification

Even a careful typist hits the wrong key now and then. Verification during data entry checks that what was typed matches the original. There are two methods. For each, say what is compared with what, and who compares.

Visual check

A person compares the screen with the original, character by character.

Original (sticker on the projector)Asset tagOn screen after typingAsset tagB4X92B4X29a person comparescharacters 4 and 5are swapped: re-enterOriginal · sticker on the projectorOn screen after typingB4X92B4X29A person compares the same positionsCharacters 4 and 5 are swapped → re-enter

Double entry

The data is typed twice; the computer compares the two entries and asks again until they match.

Pseudocodethe computer compares the two entries
DECLARE First, Second : STRING
REPEAT
OUTPUT "Enter the asset tag"
INPUT First
OUTPUT "Enter the asset tag again"
INPUT Second
IF First <> Second THEN
OUTPUT "Entries differ: enter the tag again"
ENDIF
UNTIL First = Second
OUTPUT "Accepted: ", First

Test run

Inputs: B4X92, B4X29, then B4X92 twice.

Enter the asset tag
Enter the asset tag again
Entries differ: enter the tag again
Enter the asset tag
Enter the asset tag again
Accepted: B4X92

Two characters were swapped in the second entry, so the tag is typed again.

Compare the two methods

Who does the comparing decides what each method can miss.

Visual checkDouble entry
Who comparesa personthe computer
What is comparedthe entered data with the original document (on screen, or a printout)two separate entries of the same data
Can missa difference the person overlooks; tiring for large amounts of datathe same mistake typed twice; takes twice as long to enter
Your turn

1 Run the pseudocode with the inputs C7K10, C7K01, C7K10, C7K10. How many times is “Entries differ” output?

2 A clerk types the same wrong tag twice. Which method misses this?

3 For each method, say who compares and what is compared with what.

  1. 1
    once: the first pair differs, the second pair matches and is accepted
  2. 2
    double entry: both entries match, so the wrong tag is accepted
  3. 3
    visual check: a person compares the entered data with the original document; double entry: the computer compares two entries of the same data
Tick what you can do now
Exam focusVisual check: a person reads the typed data against the source document. Double entry: the data is typed twice and the computer compares the two. “Checks it is as intended” does not name the comparison, so it earns nothing.
Practise with s26/12 Q2(a); s26/13 Q1
10 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Validation checks

§6.2 · Data integrity · data validation

Software cannot tell whether a value is true, but it can catch one that breaks a rule. Validation is carried out by software as data is entered: data that breaks a rule is rejected before it is stored. An existence check is also called a look-up check.

The validation checks, each applied to a field

Each row: the check, its rule, a field it suits, and one value it accepts and one it rejects.

CheckRule it appliesField and ruleAccepted ✓ / rejected ✗
Rangea lower and an upper boundOven temperature: 150 to 250180 ✓ · 270 ✗
Limita single boundTickets per order: at most 64 ✓ · 9 ✗
Presencenot left blankSurname must be entered"Osei" ✓ · "" ✗
Lengthnumber of characters in boundsPassword: 8 to 20 characters"bluefinch42" ✓ · "cat5" ✗
Formata set pattern of charactersLocker code, e.g. L42-B"L42-B" ✓ · "L4B" ✗
Existenceone of the stored or allowed valuesShirt size: S, M or L"M" ✓ · "XL" ✗
Check digitthe recalculated digit matchesMember number: digit sum MOD 10"73583" ✓ · "73593" ✗
Typethe expected data typeQuantity: a whole number"7" ✓ · "7.5" ✗
CheckRule and examples
Rangea lower and an upper bound
Oven temperature: 150 to 250
180 ✓ · 270 ✗
Limita single bound
Tickets per order: at most 6
4 ✓ · 9 ✗
Presencenot left blank
Surname must be entered
"Osei" ✓ · "" ✗
Lengthnumber of characters in bounds
Password: 8 to 20 characters
"bluefinch42" ✓ · "cat5" ✗
Formata set pattern of characters
Locker code, e.g. L42-B
"L42-B" ✓ · "L4B" ✗
Existenceone of the stored or allowed values
Shirt size: S, M or L
"M" ✓ · "XL" ✗
Check digitthe recalculated digit matches
Member number: digit sum MOD 10
"73583" ✓ · "73593" ✗
Typethe expected data type
Quantity: a whole number
"7" ✓ · "7.5" ✗

One field, several checks: renewal date 18/09/2030

Each numbered check tests something different about the same date. A value can pass one check and fail another.

CheckApplied to this field
Presencethe date cannot be left blank
Formatdd/mm/yyyy: two digits, /, two digits, /, four digits
Lengthexactly 10 characters
Rangefrom 01/01/2030 to 31/12/2030, including both dates
Typemust be a valid DATE
Renewal date1d8d//0m9m//2y0y3y0y10 characters12345DATE
  1. 1
    Presence: the box cannot be left blank.
  2. 2
    Format: dd/mm/yyyy: two digits, /, two digits, /, four digits.
  3. 3
    Length: exactly 10 characters.
  4. 4
    Range: from 01/01/2030 to 31/12/2030, both dates included.
  5. 5
    Type: it must be a valid DATE.

Do not confuse

  • Range has two bounds, limit has one: they do not count as two different methods in one answer. Apply each check to the field: “4 to 99”, not “checks the range”.
  • Presence: something was entered. Existence: the value is one that is allowed or already stored.
  • Format is the pattern; length is the number of characters.
Your turn

1 A field holds a shirt size: S, M or L. Which check rejects “XL”?

2 Tickets per order: at most 6. Is this a range check or a limit check? Is 6 accepted?

3 Which check would reject the renewal date 18/9/2030, and why?

  1. 1
    existence (look-up): XL is not one of the allowed values
  2. 2
    a limit check (one bound); 6 is accepted
  3. 3
    format (and length): it has 9 characters, not the dd/mm/yyyy pattern of 10
Tick what you can do now
Exam focusAsked for validation checks? Visual check and double entry are verification, and earn nothing here.
Practise with s26/12 Q2(b); s26/13 Q1; w25/13 Q7(e)
11 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Validation in pseudocode: name the check

§6.2 · Data integrity · data validation

Each program below rejects some inputs, but which check is it? Every validation check is an IF statement: read what the condition tests, not the message it outputs.

Checks on the value: bounds, blanks and lists

In each panel, find the IF line and read only its condition: how many bounds, an empty string, or a list.

Range checktwo bounds
DECLARE Score : INTEGER
INPUT Score
IF Score < 1 OR Score > 40 THEN
OUTPUT "Rejected"
ENDIF
Limit checkone bound
DECLARE Tickets : INTEGER
INPUT Tickets
IF Tickets > 6 THEN
OUTPUT "Too many tickets"
ENDIF
Presence checkan empty string
DECLARE Surname : STRING
INPUT Surname
IF Surname = "" THEN
OUTPUT "Enter a surname"
ENDIF
Existence checka list of allowed values
DECLARE Size : STRING
INPUT Size
IF Size <> "S" AND Size <> "M" AND Size <> "L" THEN
OUTPUT "No such size"
ENDIF

Checks on the characters: format and length

These look at the characters of the input, not its value: one counts them with LENGTH, the other looks for a required character.

Format checka required character
DECLARE Code : STRING
DECLARE Pos, Hyphens : INTEGER
INPUT Code
Hyphens ← 0
FOR Pos ← 1 TO LENGTH(Code)
IF MID(Code, Pos, 1) = '-' THEN
Hyphens ← Hyphens + 1
ENDIF
NEXT Pos
IF Hyphens <> 1 THEN
OUTPUT "Code needs one hyphen"
ENDIF
Length checkuses LENGTH()
DECLARE Code : STRING
INPUT Code
IF LENGTH(Code) < 5 OR LENGTH(Code) > 9 THEN
OUTPUT "Code must be 5 to 9 characters"
ENDIF

How to tell them apart

  • Two bounds → range; one bound → limit.
  • = "" → presence; a list of allowed values → existence.
  • LENGTH() → length; a pattern or required character → format.
  • A digit recalculated from the others → check digit.
  • The data type is tested, e.g. a whole number → type check.
Your turn

1 Name the check: IF Weight > 30 THEN

2 Name the check: IF Weight < 1 OR Weight > 30 THEN

3 Name the check: IF LENGTH(PostCode) <> 7 THEN

4 Name the check: IF Colour <> "Red" AND Colour <> "Blue" THEN

  1. 1
    limit: one bound
  2. 2
    range: two bounds
  3. 3
    length: it uses LENGTH()
  4. 4
    existence: the value must be one of a list
Tick what you can do now
Exam focusName the check from what the condition tests, not from the field: Score > 40 alone is a limit check; Score < 1 OR Score > 40 is a range check. When each answer must be a different method, do not name the same check twice.
Practise with w25/13 Q7(e); s26/22 Q1(a)(ii); s21/11 Q6(b) (older paper)
12 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Check digits

§6.2 · Data integrity · data validation

One mistyped digit in a barcode could charge you for the wrong item. A check digit is an extra digit calculated from the other digits of a number, such as an ID or a barcode, and stored at the end. When the number is entered, the digit is recalculated and compared.

Method 1: sum of the digits MOD 10

Add the four digits, keep the remainder after dividing by 10, and append it. Then recalculate it for each entry: which mistake gets through?

7+3+5+8=2323 MOD 10 = 3remainder = check digit73583stored numberoriginal numberOriginal number: 7358Add its digits7 + 3 + 5 + 8 = 23Calculate the check digit23 MOD 10 = 3Use the remainderStore the number with its check digit73583
EnteredWhat happenedSum → MOD 10Last digitOK
73583correct entry7+3+5+8 = 23 → 33✓
73593one digit mistyped7+3+5+9 = 24 → 43✗
37583first two digits swapped3+7+5+8 = 23 → 33✓

Method 1 in pseudocode, and a weighted method

Work through the weighted sum first: each position has its own weight, so a swap changes the total. In the code, AddCheck builds the stored number and TestCheck recalculates the last digit.

Method 2: weighted sum MOD 11

an ISBN-style scheme · weights 5, 4, 3, 2 for four digits
6 × 5 + 1 × 4 + 8 × 3 + 3 × 2 = 6464 MOD 11 = 9; 11 − 9 = 2stored as 61832

Remainder 0 gives check digit 0; remainder 1 gives 10, written X.

Swap the first two digits: 1 × 5 + 6 × 4 + 8 × 3 + 3 × 2 = 59, giving check digit 7, not 2: rejected. Each position has its own weight, so swapped digits change the total.

AddCheck uses MOD and DIV · TestCheck uses a string
FUNCTION AddCheck(Code : INTEGER) RETURNS INTEGER
DECLARE Sum, Rest : INTEGER
Sum ← 0
Rest ← Code
WHILE Rest > 0
Sum ← Sum + (Rest MOD 10)
Rest ← Rest DIV 10
ENDWHILE
RETURN Code * 10 + (Sum MOD 10)
ENDFUNCTION

FUNCTION TestCheck(Code : INTEGER) RETURNS BOOLEAN
DECLARE Digits : STRING
DECLARE Sum, Pos : INTEGER
Digits ← NUM_TO_STR(Code)
Sum ← 0
FOR Pos ← 1 TO LENGTH(Digits) - 1
Sum ← Sum + STR_TO_NUM(MID(Digits, Pos, 1))
NEXT Pos
RETURN (Sum MOD 10) = STR_TO_NUM(RIGHT(Digits, 1))
ENDFUNCTION
Your turn

1 Method 1: find the check digit for 4629 and write the stored number.

2 Method 1: is 52147 a valid number? Show the check.

3 Method 2 (weights 5, 4, 3, 2, then MOD 11): find the check digit for 2508.

  1. 1
    4 + 6 + 2 + 9 = 21; 21 MOD 10 = 1; stored as 46291
  2. 2
    5 + 2 + 1 + 4 = 12; 12 MOD 10 = 2, not 7: invalid
  3. 3
    2 × 5 + 5 × 4 + 0 × 3 + 8 × 2 = 46; 46 MOD 11 = 2; 11 − 2 = 9
Tick what you can do now
Exam focusUse the algorithm the question gives, on the original digits only. To check a number, recalculate and compare with its last digit. A plain digit sum misses swapped digits; a weighted sum with these weights catches a swap of different digits.
Practise with w25/21 Q6(a), (b); w25/23 Q6(a), (b)
13 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Parity check: adding a parity bit

§6.2 · Data integrity · verification during data transfer

Interference during transfer can flip a bit: a 0 arrives as a 1, or a 1 as a 0. A parity check adds one parity bit to each byte so that the receiver can tell when a bit has changed.

The sender sets the parity bit

Sender and receiver agree on odd or even parity. Count the 1s in the 7 data bits. Set the parity bit (here the rightmost bit, in blue) so the total, parity bit included, is even (even parity) or odd (odd parity).

7 data bitscounteven parity byteodd parity byte10110014 ones101100101011001111010115 ones1101011111010110

1011001 · 4 ones

Even parity

10110010

Odd parity

10110011

1101011 · 5 ones

Even parity

11010111

Odd parity

11010110

The receiver counts the 1s in each byte

Even parity. Sent: 10110010. Bits changed in transfer are shown in amber.

No error101100104 ones✓ even: acceptedOne bit flipped101000103 ones✗ odd: error detectedTwo bits flipped111101106 ones✓ even: accepted, but the byte is wrong

No error

10110010

4 ones · ✓ even: accepted

One bit flipped

10100010

3 ones · ✗ odd: error detected

Two bits flipped

11110110

6 ones · ✓ even: accepted, but the byte is wrong

The function counts the 1s and appends Ones MOD 2: 0 when the count is already even, 1 when it is odd.

Appending an even parity bit
FUNCTION AddEvenParity(Bits : STRING) RETURNS STRING
DECLARE Ones, Pos : INTEGER
Ones ← 0
Pos ← 1
WHILE Pos <= LENGTH(Bits)
IF MID(Bits, Pos, 1) = '1' THEN
Ones ← Ones + 1
ENDIF
Pos ← Pos + 1
ENDWHILE
RETURN Bits & NUM_TO_STR(Ones MOD 2)
ENDFUNCTION

Limitations

  • Detects any odd number of changed bits in a byte.
  • If two bits change, the count keeps its parity: not detected.
  • Shows that a byte is wrong, not which bit: the byte is sent again.
Your turn

1 Add an even parity bit (rightmost) to the 7 data bits 0110100.

2 Add an odd parity bit to the same data bits.

3 Even parity is used. The byte 11010110 arrives. Is it accepted?

  1. 1
    3 ones, so the parity bit is 1: 01101001
  2. 2
    parity bit 0: 01101000
  3. 3
    no: it has 5 ones, an odd number, so an error is detected and the byte is sent again
Tick what you can do now
Exam focusCount the 1s, including the parity bit. Use the parity (odd or even) and the bit position (leftmost or rightmost) the question states. The parity bit is whatever makes the count match: odd parity does not mean the parity bit is 1.
Practise with s24/11 Q5(b); w25/12 Q6(c)(i); s24/13 Q7(f)(i); w25/13 Q7(c); s25/23 Q5
14 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Parity block check

§6.2 · Data integrity · verification during data transfer

A parity bit shows that a byte is wrong, but not which bit. Checking the columns too pins the error down. Each byte has its own parity bit (horizontal parity). A parity byte, here the extra byte of column parity bits sent after the block, checks each column (vertical parity).

The sender builds the block

Read the grid two ways: across each byte for its parity bit P, then down each column for the parity byte.

1234567P
Byte 110100110
Byte 201110001
Byte 311001010
Byte 400111100
Parity byte00100001
1
Even parity. Each byte: 7 data bits, then a parity bit P that makes its number of 1s even.
2
For each column, count the 1s down it, parity bits included; set that bit of the parity byte to make the count even.
3
Send the four bytes, then the parity byte.

Odd parity reverses the rule: a byte whose 7 data bits hold an even number of 1s gets parity bit 1.

The receiver locates the error

Find the byte marked ✗ and the column marked ✗: the error is the bit where they cross.

1234567P
Byte 110100110✓
Byte 201110001✓
Byte 311011010✗
Byte 400111100✓
Parity byte00100001✓
column✓✓✓✗✓✓✓✓
1
Recount the 1s in every byte: byte 3 is odd, so it contains the error.
2
Recount every column: column 4 is odd.
3
The changed bit is where the failing row and column cross: byte 3, bit 4.
4
Flip it back: the data is corrected without being sent again.
Limitation. Two bits changed in one byte: no byte fails but two columns do, so the block is resent.
Your turn

1 Even parity. Two bytes have the data bits 1100110 and 1010101. Give each byte with its parity bit.

2 Now give the parity byte for this two-byte block.

3 At the receiver, byte 2 and column 6 fail. What is wrong, and what does the receiver do?

  1. 1
    11001100 and 10101010
  2. 2
    01100110: with it, each column has an even number of 1s
  3. 3
    bit 6 of byte 2 has changed: the receiver flips it back, with no need to resend
Tick what you can do now
Exam focusDescribe it in these steps: data sent in groups of 7 bits; both computers agree odd or even; a parity bit per byte; the 1s in each column are counted to make a parity byte; the failing row and column give the position of the error.
Practise with w25/12 Q6(c)(ii); w25/13 Q7(c); w25/12 Q1; s24/11 Q5(b); s24/13 Q7(f)(i)
15 / 16
9618 · Unit 6 · Security, privacy and data integrity
Revisionbyexamplicity

Checksums, and choosing a check

§6.2 · Data integrity · verification during data transfer

Parity checks one byte or one column at a time. A checksum checks a whole block at once: it is one value worked out from the block with an agreed algorithm. It travels with the block, and the receiver works it out again to compare.

Follow the block from sender to receiver: one byte changes on the way, so the receiver’s result no longer matches 137.

SENDERRECEIVER72101108112data bytes137checksum393 MOD 256 = 137data + checksumsent together72100108112137received datareceived392 MOD 256 = 136136 ≠ 137 → error detectedrequest to resend→ resends the blockSENDERRECEIVER72101108112data bytes137checksum393 MOD 256 = 137data + checksumsent together72100108112137received datareceived392 MOD 256 = 136136 ≠ 137 → error detectedRequest → sender resends the block

Worked example: checksum = (sum of the bytes) MOD 256

Each row adds the four bytes and keeps the remainder after dividing by 256. The last row shows two changes that cancel out.

ReceivedBytesSumMOD 256Compared with 137
No error72 101 108 112393137✓ matches: accepted
One byte changed72 100 108 112392136✗ differs: error
Two changes cancel out72 100 109 112393137✓ matches: error missed

The data is the ASCII codes of “Help”. A checksum task names its algorithm (a plain sum, the sum MOD 256, or another calculation): use exactly the one given.

Which check, when?

All six checks in one place: be able to choose one for a situation and say whether it can find where the error is.

MethodUsed duringDetects an errorCan locate it
Visual checkdata entryby a person comparing with the originalthe person sees where
Double entrydata entrythe two entries differno
Check digitdata entry (validation)recalculated digit differsno
Parity bytedata transfera byte has the wrong parityno: the byte is resent
Parity blockdata transfera byte or column has the wrong parityyes, for one wrong bit
Checksumdata transferrecalculated checksum differsno: the block is resent
Do not confuse the two. A check digit is one digit inside a number, recalculated at entry. A checksum is a value for a whole block, sent with it during transfer.
Your turn

1 The block 10, 200, 90 is sent with checksum = (sum of the bytes) MOD 256. What is the checksum?

2 The receiver gets 10, 201, 90 and the checksum you found. What does it do?

3 Which check can correct one wrong bit without a resend?

  1. 1
    10 + 200 + 90 = 300; 300 MOD 256 = 44
  2. 2
    it recalculates 301 MOD 256 = 45; 45 ≠ 44, so it asks for the block again
  3. 3
    a parity block: the failing row and column locate the bit
Tick what you can do now
Exam focusThree steps earn the marks: 1 the sender computes a checksum from the block and sends it along; 2 the receiver computes it again from what arrives; 3 it compares the two, and a difference means an error.
Practise with s25/11 Q7(c); s24/13 Q7(f)(i); w25/13 Q7(c); s26/13 Q1; w25/12 Q1
16 / 16